Product of coprimes

Time Limit: 1000ms
Memory Limit: 32768KB
This problem will be judged on HDU. Original ID: 3508
64-bit integer IO format: %I64d      Java class name: Main

Description

You are given a positive integer m. Calculate the product of all positive integers less then or equal to m and coprime with m, and give the answer modulo m.

Input

There are multiple tests end with EOF, each test contains only a positive integer m ≤ 10^9 in a line. The number of tests is no more than 5000.

Output

In the output file you should write the answer to the task.

Sample Input

1
2
3
4
5
6
7

Sample Output

0
1
2
3
4
5
6

Source

Language: 
Theme: 
Share Code? 

Powered by NB231 | Current Style: .