Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Life of Phi II

Limits 1s, 512 MB

You will be given two integers nn and mm where GCD(n,m)=1GCD(n, m) = 1. You have to tell that how many numbers are there from 11 to m×nm×n that is co-prime to:

  1. nn but not with mm,
  2. mm but not with nn, and
  3. both mm and nn.

Input

The only line of input contains two integers nn and mm (1n,m1061 ≤ n, m ≤ 10^6). It is guaranteed that nn and mm are relatively prime.

Output

Output three numbers as mentioned above.

Samples

InputOutput
2 3
1 2 2
InputOutput
5 7
4 6 24

Please note that for relatively prime numbers nn and mm, Phi(n×m)=Phi(n)×Phi(m)Phi(n×m) = Phi(n)×Phi(m).

Discussion

Toph uses cookies. By continuing you agree to our Cookie Policy.