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).

Submit

Login to submit.

Contributors

Statistics

62% Solution Ratio
user.072346Earliest, Sep '19
steinumFastest, 0.0s
Ud_udoyLightest, 0 B
bokaifShortest, 206B
Toph uses cookies. By continuing you agree to our Cookie Policy.