import java.io.*;
import java.util.*;

public class gcm_dp_java {
    BufferedReader br;
    StringTokenizer in;
    PrintWriter out;

    public String nextToken() throws IOException {
        while (in == null || !in.hasMoreTokens()) {
            in = new StringTokenizer(br.readLine());
        }
        return in.nextToken();
    }

    public int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    public double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    public long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    public static void main(String[] args) throws IOException {
        new gcm_dp_java().run();
    }

    int gcd(int a, int b) {
        while (b > 0) { 
            a %= b;
            int t = a;
            a = b;
            b = t;
        }
        return a;
    }

    long lcm(int a, int b) {
        return 1L * a / gcd(a, b) * b;
    }

    class Pair {
        int first, second;
        
        Pair(int first, int second) {
            this.first = first;
            this.second = second;
        }
    }

    int factorize(int number, Pair[] primes) {
        int size = 0;
        for (int i = 2; i * i <= number; i++) {
            int cnt = 0;
            while (number % i == 0) {
                cnt++;
                number /= i;
            }
            if (cnt > 0)
                primes[size++] = new Pair(i, cnt);
        }
        if (number > 1) {
            primes[size++] = new Pair(number, 1);
        }
        return size;
    }

    long power(int x, int p) {
        long ans = 1;                                                 
        for (int i = 0; i < p; i++)
            ans *= x;
        return ans;
    }

    long bestAns = 0, bestX, bestY;
    long x = 1, y = 1;

    void go(int pos, int size, long[] primes) {
        if (pos == size) {
            if (bestAns > Math.abs(x - y)) {
                bestAns = Math.abs(x - y);
                bestX = x;
                bestY = y;
            }
            return;
        }

        x *= primes[pos];
        go(pos + 1, size, primes);
        x /= primes[pos];

        y *= primes[pos];
        go(pos + 1, size, primes);
        y /= primes[pos];
    }

    final int MAX_SIZE = 50;

    public void solve() throws IOException {
        int a = nextInt();
        int b = nextInt();

        int d = gcd(a, b);
        Pair[] a_primes = new Pair[MAX_SIZE];
        Pair[] b_primes = new Pair[MAX_SIZE];
        int a_size = factorize(a / d, a_primes);
        int b_size = factorize(b / d, b_primes);
            
        int p1 = 0, p2 = 0;                    
        long[] primes = new long[2 * MAX_SIZE];
        int size = 0;
        while (p1 < a_size && p2 < b_size) {
            if (a_primes[p1].first < b_primes[p2].first) {
                primes[size++] = power(a_primes[p1].first, a_primes[p1].second);
                p1++;
            } else if (a_primes[p1].first == b_primes[p2].first) {
                primes[size++] = power(a_primes[p1].first, a_primes[p1].second + b_primes[p2].second);
                p1++;
                p2++;
            } else {
                primes[size++] = power(b_primes[p2].first, b_primes[p2].second);
                p2++;
            }
        }

        while (p1 < a_size) {
            primes[size++] = power(a_primes[p1].first, a_primes[p1].second);
            p1++;
        }
        while (p2 < b_size) {
            primes[size++] = power(b_primes[p2].first, b_primes[p2].second);
            p2++;
        }

        bestAns = Math.abs(b - a) / d;
        bestX = a / d;
        bestY = b / d;
        go(0, size, primes);

        if (bestX > bestY) {
            long t = bestX;
            bestX = bestY;
            bestY = t;
        }
        out.println(bestX * d + " " + bestY * d);
    }

    public void run() {
        try {
            br = new BufferedReader(new FileReader("gcm.in"));
            out = new PrintWriter("gcm.out"); 
            solve();

            out.close();
        } catch (IOException e) {
            e.printStackTrace();
            System.exit(1);
        }
    }
}