Hide

Problem A
Shanks' Baby Step Giant Step

Languages en is

Implement the baby-step giant-step algorithm to solve gxh(modp) for x.

Input

Input is three lines. The first line contains the prime p where 3p<240. The second line contains the integer g where 2g<p of order at least 2. The third line contains the integer h where 0h<p.

Output

Output one line with any valid solution 0x<p1 or no solution if no solution exists.

Sample Input 1 Sample Output 1
367
2
137
75
Sample Input 2 Sample Output 2
367
2
179
no solution
Hide

Please log in to submit a solution to this problem

Log in