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 java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
 
public class Main
{
    
    static class InputReader {

		private final InputStream stream;
		private final byte[] buf = new byte[8192];
		private int curChar, snumChars;

		public InputReader(InputStream st) {
			this.stream = st;
		}

		public int read() {
			if (snumChars == -1)
				throw new InputMismatchException();
			if (curChar >= snumChars) {
				curChar = 0;
				try {
					snumChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (snumChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public int ni() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public long nl() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public int[] nia(int n) {
			int a[] = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = ni();
			}
			return a;
		}

		public String rs() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public String nextLine() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndOfLine(c));
			return res.toString();
		}

		public boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		private boolean isEndOfLine(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

	}

	static void gcd(long a, long b,PrintWriter w)
    {
	 if (a == 0 || b == 0)
	 {
	  w.println(a + " " + b);
	  return;
	 }
	 else if(a <2*b && b <2*a)
	 {
	      w.println(a + " " + b);
	      return;
	 }
	 
	else if(a >= 2*b)			         
	 gcd(a%(2*b),b,w);
	 else if(b >= 2*a)
	 gcd(a,b%(2*a),w);
    }



    public static void main(String[] args)
    {
        
        InputReader sc = new InputReader(System.in);
        PrintWriter w = new PrintWriter(System.out);
        long x = sc.nl();
        long y = sc.nl();
        gcd(x,y,w);
    
        
       /*
        int x = sc.ni();
        int y = sc.ni();
        String [][]arr = new String[x+2][y+2];
        for(int i=1;i<=x;i++)
        {
            for(int j=1;j<=y;j++)
            {
                arr[i][j] = sc.rs();
            }
        }
        int c = 0;
        for(int i=1;i<=x;i++)
        {
            for(int j=1;j<=y;j++)
            {
                if(arr[i][j].equals("S"))
                {
                    if(arr[i-1][j].equals("W") ||arr[i+1][j].equals("W")||arr[i][j-1].equals("W")||arr[i][j+1].equals("W"))
                    c++;
                }
            }
        }
        if(c != 0)
        w.println("No");
        else
        {
            for(int i=1;i<=x;i++)
        {
            for(int j=1;j<=y;j++)
            {
                if(arr[i][j].equals("S"))
                {
                    if(arr[i-1][j].equals("."))
                    arr[i-1][j].replace(".","D");
                    
                    if(arr[i+1][j].equals("."))
                    arr[i+1][j].replace(".","D");
                    
                    if(arr[i][j+1].equals("."))
                    arr[i][j+1].replace(".","D");
                    
                    if(arr[i][j-1].equals("."))
                    arr[i][j-1].replace(".","D");
                    
                    
                }
            }
        }
        w.println("Yes");
        
        for(int i=1;i<=x;i++)
        {
            for(int j=1;j<=y;j++)
            {
                w.print(arr[i][j]);
                
            }
            w.println();
        }
        }
        
        */
        
        
        /*
        118B
        int x = sc.ni();
        int res = x*2;
        String [][]arr = new String[res+ 1][res+1];
        
        for(int i=0;i<=x*2;i++)
        {
            for(int j=x-i;j<=x+i;j++)
            {
                if(j <= x)
                    arr[i][j] = ips(i+j-x);
                    else
                     arr[i][j] = ips(2*x -i - j);
                
            }
            
        }
        for(int i=0;i<=x*2;i++)
        {
            for(int j=0;j<=x*2;j++)
            {
                w.print(arr[i][j] + " ");
                
            }
            w.println();
        }
    */
       
        
        
        
          
       
       
      
       
        
        
        
           
        
       
           
           
        
        
        
    
        w.close();
        

        
    }
    
    static boolean[] sieveOfEratosthenes(int n)
    {
        // Create a boolean array "prime[0..n]" and initialize
        // all entries it as true. A value in prime[i] will
        // finally be false if i is Not a prime, else true.
        boolean prime[] = new boolean[n+1];
        for(int i=0;i<n;i++)
            prime[i] = true;
         
        for(int p = 2; p*p <=n; p++)
        {
            // If prime[p] is not changed, then it is a prime
            if(prime[p] == true)
            {
                // Update all multiples of p
                for(int i = p*2; i <= n; i += p)
                    prime[i] = false;
            }
        }
         
        // Print all prime numbers
        
        return prime;
    }
    static int log2(int value) {
    return Integer.SIZE-Integer.numberOfLeadingZeros(value);
}

public static void permutation(String str) { 
    permutation("", str); 
}

private static void permutation(String prefix, String str) {
    int n = str.length();
    if (n == 0) System.out.println(prefix);
    else {
        for (int i = 0; i < n; i++)
            permutation(prefix + str.charAt(i), str.substring(0, i) + str.substring(i+1, n));
    }
}

 
    
    /*
    static boolean is(int p,int x,int y)
    {
        int flag = 0;
        
            for(int j=2;j<=p;j++)
            {
                if(x % j == 0)
                {
                    flag = 1;
                    break;
                }
                else 
                continue;
                
            }
            
        if(flag == 1)
        return false;
        else
        return true;
        
    }
    */
    static int binarysearch(int []arr,int p,int n)
    {
        
        int st = 0;
        int end = n-1;
        int mid = (st + end)/2;
        int temp = 0;
        while(st < end)
        { 
            mid = (st + end)/2;
        
            if(p > arr[mid])
            {
                st = mid+1;
                
            }
            else if(p < arr[mid])
            {
                end = mid;
                
            }
            else if(p == arr[mid])
            {
            temp = mid;
            break;
            }
            
            
            
        }
        if(st == end)
        temp = st;
        
        return temp;
    }
    
   
    static class Student
    {
        
        int floor;
        int time;
        Student(int floor,int time)
        {
            this.floor = floor;
            this.time = time;
            
            
        }
        
    }
    static int lis(int arr[],int n)
    {
          int lis[] = new int[n];
          int i,j,max = 0;
 
          /* Initialize LIS values for all indexes */
           for ( i = 0; i < n; i++ )
              lis[i] = 1;
 
           /* Compute optimized LIS values in bottom up manner */
           for ( i = 1; i < n; i++ )
              for ( j = 0; j < i; j++ ) 
                         if ( arr[i] > arr[j] && lis[i] <= lis[j])
                    lis[i]++;
 
           /* Pick maximum of all LIS values */
           for ( i = 0; i < n; i++ )
              if ( max < lis[i] )
                 max = lis[i];
 
            return max;
    }
    
    
    public static int ip(String s){
		return Integer.parseInt(s);
	}
	 public static String ips(int s){
		return Integer.toString(s);
	}
	
    
					 
}
