Hide

Problem F
Primitive Roots

Languages en is

Primitive roots modulo m are values g such that gϕ(m)=1(modm) but gk1(modm) for all k<ϕ(m).

Such values only exist if m=1,2,4,pk or 2pk where p is an odd prime and k1.

Find such a value g for m or report that it does not exist.

Input

The first and only line of input contains a positive integer m>1.

Output

Print a primitive root g modulo m. It should satisfy 0g<m. If no such root exists, print 1.

Sample Input 1 Sample Output 1
5
2
Sample Input 2 Sample Output 2
13
2
Sample Input 3 Sample Output 3
202
3
Sample Input 4 Sample Output 4
91
-1
Hide

Please log in to submit a solution to this problem

Log in