#P16634. [GKS 2017 #G] Huge Numbers
[GKS 2017 #G] Huge Numbers
Problem Description
Professor Shekhu has another problem for Akki today. He has given him three positive integers , and and wants him to calculate the remainder when is divided by . As usual, denotes the product of the first positive integers.
Input Format
The first line of the input gives the number of test cases, . lines follow. Each line contains three integers , and , as described above.
Output Format
For each test case, output one line containing Case #x: y, where is the test case number (starting from ) and is the answer.
2
2 1 2
3 3 2
Case #1: 0
Case #2: 1
Hint
In Sample Case , the answer is the remainder when is divided by , which is .
In Sample Case , the answer is the remainder when is divided by , which is .
Limits
.
Small dataset (Test set 1 - Visible)
.
.
.
Large dataset (Test set 2 - Hidden)
.
.
.