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;
  2. If a ≥ 2·b, then set the value of a to a - 2·b, and repeat step 1. Otherwise, go to step 3;
  3. 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.

Input

The only line of the input contains two integers n and m (1 ≤ n, m ≤ 1018). n is the initial value of variable a, and m is the initial value of variable b.

Output

Print two integers — the values of a and b after the end of the process.

Examples

Input

12 5


Output

0 1


Input

31 12


Output

7 12

Note

Explanations to the samples:

  1. a = 12, b = 5 <image> a = 2, b = 5 <image> a = 2, b = 1 <image> a = 0, b = 1;
  2. a = 31, b = 12 <image> a = 7, b = 12.
import math
from fractions import Fraction

def modInverse(a, m) :
	
	g = gcd(a, m)
	
	if (g != 1) :
		print("Inverse doesn't exist")
		
	else :
		res = power(a, m - 2, m)
		return res
	
# To compute x^y under modulo m
def power(x, y, m) :
	
	if (y == 0) :
		return 1
		
	p = power(x, y // 2, m) % m
	p = (p * p) % m

	if(y % 2 == 0) :
		return p 
	else : 
		return ((x * p) % m)

# Function to return gcd of a and b
def gcd(a, b) :
	if (a == 0) :
		return b
		
	return gcd(b % a, a)

def modulo(a, m):
	return (a%m+m)%m




def matrix_square(A, mod):
    return mat_mult(A,A,mod)


def mat_mult(A,B, mod):
  if mod is not None:
    return [[modulo(A[0][0]*B[0][0] + A[0][1]*B[1][0], MOD), modulo((A[0][0]*B[0][1] + A[0][1]*B[1][1]), MOD)],
            [modulo((A[1][0]*B[0][0] + A[1][1]*B[1][0]), MOD), modulo((A[1][0]*B[0][1] + A[1][1]*B[1][1]), MOD)]]


def matrix_pow(M, power, mod):
    #Special definition for power=0:
    if power <= 0:
      return M

    powers =  list(reversed([True if i=="1" else False for i in bin(power)[2:]])) #Order is 1,2,4,8,16,...

    matrices = [None for _ in powers]
    matrices[0] = M

    for i in range(1,len(powers)):
        matrices[i] = matrix_square(matrices[i-1], mod)


    result = None

    for matrix, power in zip(matrices, powers):
        if power:
            if result is None:
                result = matrix
            else:
                result = mat_mult(result, matrix, mod)

    return result

def power(x, y, p) :
    res = 1     # Initialize result
 
    # Update x if it is more
    # than or equal to p
    x = x % p 
 
    while (y > 0) :
         
        # If y is odd, multiply
        # x with result
        if ((y & 1) == 1) :
            res = (res * x) % p
 
        # y must be even now
        y = y >> 1      # y = y/2
        x = (x * x) % p
         
    return res
'''
for _ in xrange(int(raw_input())):
	l, d, t = map(int, raw_input().split())
	MOD = 1000000007

	if(t==1):
		print d
		continue
	
	fib_matrix = [[2*d,l],[-l,0]]
 	
 	res = matrix_pow(fib_matrix, t-1, MOD)
	num = modulo((d*res[0][0]-l*res[0][1]), MOD)
	
	denom = power(l, t-1, MOD)
	
	k = gcd(num, denom)
	num/=k
	denom/=k
	
	num = modulo(num, MOD)
	denom = modInverse(denom, MOD)
	print modulo(num*denom, MOD)
'''

def inp(): return input()

def inpv(): return [int(x) for x in raw_input().split()]

def Hills():
	x = inpv()#map(int, raw_input.split())
	a = x[0]
	b = x[1]
	while(a>0 and b>0):
		if(a>=b+b):
			a%=b+b
		elif (b>=a+a):
			b%=a+a
		else:
			break
	print a,b

		
Hills()
