SP3105 MOD - Power Modulo Inverted

Description

Given 3 positive integers $x,y$ and $z$, you can find $k = x ^y \bmod z$ easily, by fast power-modulo algorithm. Now your task is the inverse of this algorithm. Given 3 positive integers $x,z$ and $k$, find the smallest non-negative integer $y$, such that $k \bmod z = x^y \bmod z$.

Input Format

About $600$ test cases. Each test case contains one line with 3 integers $x,z$ and $k$. ( $1 \le x,z,k \le 10^9$ ) Input terminates by three zeroes.

Output Format

For each test case, output one line with the answer, or "No Solution"(without quotes) if such an integer doesn't exist.