Given
find f(a, b) mod m.
The first line will contain a single integer T (T <= 10), the number of test cases. Following T lines will contain 3 space-separated integers: a, b, m (1 <= a, b, m <= 10^18).
Print T lines denoting the answer. Print a newline after each output.
Input | Output |
---|---|
1 3 2 1000 | 27 |