Interesting equation#561

Interesting equation

5 seconds
64 megabytes
Very hard

Little Y found an interesting mathematical equation:

X^Y \bmod Z = K

He quickly learned to calculate when , , and are given. But now, he is interested in how to quickly find given , , and . Help him with this task.

Input

The first line contains the number of test cases (0 < T < 21). Each of the next lines contains three integers: , , (0 \leq X, Z, K \leq 10^9).

Output

For each test case, output on a separate line the minimal possible (0 \leq Y < Z), or if there is no solution, output "No Solution".

Examples

Example 1

Loading
Loading