MOD  Power Modulo Inverted
Given 3 positive integers x, y and z, you can find k = x^{y}%z easily, by fast powermodulo algorithm. Now your task is the inverse of this algorithm. Given 3 positive integers x, z and k, find the smallest nonnegative integer y, such that k%z = x^{y}%z.
Input
About 600 test cases.
Each test case contains one line with 3 integers x, z and k.(1<= x, z, k <=10^{9})
Input terminates by three zeroes.
Output
For each test case, output one line with the answer, or "No Solution"(without quotes) if such an integer doesn't exist.
Example
Input: 5 58 33 2 4 3 0 0 0 Output: 9 No Solution
hide comments
ashish kumar:
20151225 05:58:50
What should be expected time complexity. My T*sqrt(n)*logn is giving TLE. 

pardeep kumar:
20120615 11:29:46
either x^y=z+k*n....for some positive integer n..OR

Added by:  Fudan University Problem Setters 
Date:  20081004 
Time limit:  4s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: C99 ERL JSRHINO NODEJS PERL6 VB.NET 
Resource:  Folklore, description, standard program and test data by Blue Mary 