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 n and m where GCD( n , m ) = 1. You have to tell that how many numbers are there from 1 to m * n that is co-prime to:

  1. n but not with m,
  2. m but not with n
  3. both m and n.

Input

The only line of input contains two integers n and m ( 1 <= n , m <= 106 ). It is guaranteed that n and m 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 n and m, Phi( n * m ) = Phi( n ) * Phi( m ).


    Discussion
    Statistics

    15% Solution Ratio

    user.072346 Earliest, 2w ago

    steinum Fastest, 0.0s

    Ud_udoy Lightest, 0 B

    Ud_udoy Shortest, 332B

    Submit

    Login to submit