Limits 500ms, 1.5 GB

One day Raju discovered USACO and from that day he would spend all his time solving problems. Laali was jealous to see Raju putting so much effort to solve problems about Farmer John’s cow Bessie.

So Laali wrote a problem about herself and asked Raju to solve it. Raju wrote the following solution only to realize it would take him very long to get any output and Laali will be highly disappointed.

take N and M as input
for i = 2 to 1,000,000,000,000
    if i is equal to the smallest divisor of M and N >= i // 1 is not considered as a divisor
        M = M / i
        N = N - i
print N and M

Now given an initial N and M, help Raju so that he can solve the problem and save the world from the wrath of Laali.

Input

Input contains two numbers N (1 ≤ N ≤ 1012) and M (1 ≤ M ≤ 1012) denoting the initial values.

Output

Output a single line containing the final values of N and M.

Samples

InputOutput
10 30
0 1
InputOutput
10 10
3 1
InputOutput
9 30
4 5

Submit

Login to submit.

Statistics

60% Solution Ratio
NirjhorEarliest, Aug '17
RuhulAminSharifFastest, 0.0s
NirjhorLightest, 131 kB
mdvirusShortest, 191B
Toph uses cookies. By continuing you agree to our Cookie Policy.