Given three numbers x,k and m, you need to find the value of xxx...x%m where number of x's in the expression are k. That is, if x=5,k=3 and m=3, then you need to compute 555%3.
Constraints:
1≤T≤105
1≤m≤107
1≤k≤1018
m<x≤108 x is always a prime number
Format of the input file:
First line : T i.e number of testcases.
For each testcase :
First line : Three space separated integers x , k and m.
Format of the output file:
Print the answer for each test case in a separate line
Case 1: 5 % 3=2
Case 2: 55 % 3=3125 % 3= 2