Interesting equation
Very hard
Execution time limit is 5 seconds
Runtime memory usage limit is 64 megabytes
Little Y finds there is a very interesting formula in mathematics:
X^Y mod Z = K
Given X, Y, Z, we all know how to figure out K fast. However, given X, Z, K, could you figure out Y fast?
Input
Input data consists of no more than 20 test cases. For each test case, there would be only one line containing 3 integers X, Z, K (0 ≤ X, Z, K ≤ 10^9).
Output
For each test case output one line. Write "No Solution" (without quotes) if you cannot find a feasible Y (0 ≤ Y < Z). Otherwise output the minimum Y you find.
Examples
Input #1
Answer #1
Submissions 604
Acceptance rate 3%