#0006F5

Modular

InputThe first line contains a positive integer N (N <= 250000).
The next N lines contain three space separated positive integers each A,B,M (2 <= A,B,M <= 10^18)

OutputOutput N lines. Each line should contain the remainder of dividing A*B by M.

Input:
1
20 5 84

Output:
16
Input:
2
5555555555555555 2222222222222222 7777777777777777
2 5 10

Output:
1111111111111111
0



Submit solution

Coming later

The grading service will be connected in a later migration step. You can inspect the task and your previous results now.