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.math.*;
import java.util.*;

public class Main {
    
    private static final class FastScanner {
        private final InputStream is = System.in;
        private final byte[] buf = new byte[8192];
        private int curChar;
        private int numChars;
 
        public FastScanner() {
        }
 
        public int read() {
                if (this.numChars == -1) {
                        throw new InputMismatchException();
                }
                if (this.curChar >= this.numChars) {
                        this.curChar = 0;
                        try {
                                this.numChars = this.is.read(this.buf);
                        } catch (final IOException e) {
                                throw new InputMismatchException();
                        }
                        if (this.numChars <= 0) {
                                return -1;
                        }
                }
                return this.buf[this.curChar++];
        }
 
        public String nextLine() {
                int c;
                while (isSpaceChar(c = read())) {
                }
                final StringBuilder res = new StringBuilder();
                do {
                        res.appendCodePoint(c);
                } while (!isEndOfLine(c = read()));
                return res.toString();
        }
 
        public String nextString() {
                int c;
                while (isSpaceChar(c = read())) {
                }
                final StringBuilder res = new StringBuilder();
                do {
                        res.appendCodePoint(c);
                } while (!isSpaceChar(c = read()));
                return res.toString();
        }
 
        public long nextLong() {
                int c;
                while (isSpaceChar(c = read())) {
                }
                boolean f = true;
                if (c == '-') {
                        f = false;
                        c = read();
                }
                long res = 0;
                do {
                        /*if (c < '0' || c > '9') {
                                throw new InputMismatchException();
                        }*/
                        res = res * 10 + c - '0';
                } while ((c = read()) >= '0' && c <= '9');
                return f ? res : -res;
        }
 
        public int nextInt() {
                int c;
                while (isSpaceChar(c = read())) {
                }
                boolean f = true;
                if (c == '-') {
                        f = false;
                        c = read();
                }
                int res = 0;
                do {
                        /*if (c < '0' || c > '9') {
                                throw new InputMismatchException();
                        }*/
                        res = res * 10 + c - '0';
                } while ((c = read()) >= '0' && c <= '9');
                return f ? res : -res;
        }
 
        public double nextDouble() {
                return Double.parseDouble(nextString());
                // return FloatingDecimal.parseDouble(nextString());
        }
 
        public BigInteger nextBigInteger() {
                return new BigInteger(nextString(), 10);
        }
 
        public BigDecimal nextBigDecimal() {
                return new BigDecimal(nextString());
        }
 
        public int[] nextArray(final int n) {
                final int[] a = new int[n];
                for (int i = 0; i < n; i++) {
                        a[i] = nextInt();
                }
                return a;
        }
 
        public long[] nextLongArray(final int n) {
                final long[] a = new long[n];
                for (int i = 0; i < n; i++) {
                        a[i] = nextLong();
                }
                return a;
        }
 
        public char[] nextCharArray(final int n) {
                final char[] bf = new char[n];
                int b, p = 0;
                while (isSpaceChar(b = read())) {
                }
                while (p < n && !isSpaceChar(b)) {
                        bf[p++] = (char) b;
                        b = read();
                }
                return n == p ? bf : Arrays.copyOf(bf, p);
        }
 
        public char[][] nextMatrix(final int n, final int m) {
                final char[][] map = new char[n][];
                for (int i = 0; i < n; i++) {
                        map[i] = nextCharArray(m);
                }
                return map;
        }
 
        public int[][] nextIntMatrix(final int n, final int m) {
                final int[][] map = new int[n][];
                for (int i = 0; i < n; i++) {
                        map[i] = nextArray(m);
                }
                return map;
        }
 
        public long[][] nextLongMatrix(final int n, final int m) {
                final long[][] map = new long[n][];
                for (int i = 0; i < n; i++) {
                        map[i] = nextLongArray(m);
                }
                return map;
        }
 
        public boolean isSpaceChar(final int c) {
                return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }
 
        public boolean isEndOfLine(final int c) {
                return c == '\n' || c == '\r' || c == -1;
        }
    }
    
    public static void main(String[] args) throws IOException {
        FastScanner in = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        StringBuilder r = new StringBuilder();        
        
        long a = in.nextLong();
        long b = in.nextLong();
        
        while(a != 0 && b != 0) {
            
            if(a >= 2*b) {
                a = a % (2*b);
            } else {
                if(b >= 2*a) {
                    b = b % (2*a);
                } else {
                    break;
                }
            }
            
        }
        
        r.append(a + " " + b + "\n");
        
        out.print(r);
        out.flush();
        out.close();
        
    }
        
}