You have two variables *a* and *b*. Consider the following sequence of actions performed with these variables:
1.  If *a* = 0 or *b* = 0, end the process. Otherwise, go to step 2;1.  If *a* ≥ 2·*b*, then set the value of *a* to *a* - 2·*b*, and repeat step 1. Otherwise, go to step 3;1.  If *b* ≥ 2·*a*, then set the value of *b* to *b* - 2·*a*, and repeat step 1. Otherwise, end the process.
Initially the values of *a* and *b* are positive integers, and so the process will be finite.

You have to determine the values of *a* and *b* after the process ends.
The only line of the input contains two integers *n* and *m* (1 ≤ *n*, *m* ≤ 10<sup class="upper-index">18</sup>). *n* is the initial value of variable *a*, and *m* is the initial value of variable *b*.
Explanations to the samples:
1.  *a* = 12, *b* = 5 <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/70a0795f45d32287dba0eb83fc4a3f470c6e5537.png" style="max-width: 100.0%;max-height: 100.0%;"/> *a* = 2, *b* = 5 <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/70a0795f45d32287dba0eb83fc4a3f470c6e5537.png" style="max-width: 100.0%;max-height: 100.0%;"/> *a* = 2, *b* = 1 <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/70a0795f45d32287dba0eb83fc4a3f470c6e5537.png" style="max-width: 100.0%;max-height: 100.0%;"/> *a* = 0, *b* = 1;1.  *a* = 31, *b* = 12 <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/70a0795f45d32287dba0eb83fc4a3f470c6e5537.png" style="max-width: 100.0%;max-height: 100.0%;"/> *a* = 7, *b* = 12.
12 5
0 1
31 12
7 12
1000000000000000000 7
8 7
31960284556200 8515664064180
14928956427840 8515664064180
1000000000000000000 1000000000000000000
1000000000000000000 1000000000000000000
1 1000
1 0
1 1000000
1 0
1 1000000000000000
1 0
1 99999999999999999
1 1
1 4
1 0
1000000000000001 500000000000000
1 0
1 1000000000000000000
1 0
2 4
2 0
2 1
0 1
6 19
6 7
22 5
0 1
10000000000000000 100000000000000001
0 1
1 1000000000000
1 0
2 1000000000000000
2 0
2 10
2 2
51 100
51 100
3 1000000000000000000
3 4
1000000000000000000 3
4 3
1 10000000000000000
1 0
8796203 7556
1019 1442
5 22
1 0
1000000000000000000 1
0 1
1 100000000000
1 0
2 1000000000000
2 0
5 4567865432345678
5 8
576460752303423487 288230376151711743
1 1
499999999999999999 1000000000000000000
3 2
1 9999999999999
1 1
103 1000000000000000000
103 196
7 1
1 1
100000000000000001 10000000000000000
1 0
5 10
5 0
7 11
7 11
1 123456789123456
1 0
5000000000000 100000000000001
0 1
1000000000000000 1
0 1
1000000000000000000 499999999999999999
2 3
10 5
0 5
9 18917827189272
9 0
179 100000000000497000
179 270
5 100000000000001
1 1
5 20
5 0
100000001 50000000
1 0
345869461223138161 835002744095575440
1 0
8589934592 4294967296
0 4294967296
4 8
4 0
1 100000000000000000
1 0
1000000000000000000 333333333333333
1000 1333
25 12
1 0
24 54
0 6
6 12
6 0
129200000000305 547300000001292
1 0
1000000000000000000 49999999999999999
20 39
1 2
1 0
1 123456789876
1 0
2 3
2 3
1 3
1 1
1 1
1 1
19 46
3 2
3 6
3 0
129 1000000000000000000
1 0
12 29
0 1
8589934592 2147483648
0 2147483648
2147483648 8589934592
2147483648 0
5 6
5 6
1000000000000000000 2
0 2
2 7
2 3
17174219820754872 61797504734333370
17174219820754872 27449065092823626
49 100
1 0
7 17
1 1
1000000000000000000 10000001
0 1
49999999999999999 2
3 2
49999999999999999 1
1 1
576460752303423487 2
3 2
19395 19395
19395 19395
19394 19394
19394 19394
import sys, copy

n, m = map(int, sys.stdin.readline().split())
while n and m:
    stop1 = True
    stop2 = True
    if m != 0 and n >= 2 * m:
        temp = n // (2 * m)
        n -= temp * 2 * m
        stop1 = False
    if n != 0 and m >= 2 * n:
        temp = m // (2 * n)
        m -= temp * 2 * n
        stop2 = False
    if stop1 and stop2:
        break

print(n, m)
