#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>

using namespace std;

#ifdef WIN32
    #define LLD "%I64d"
#else
    #define LLD "%lld"
#endif

const int MAX_IT = 3e7;

long long gcd(long long x, long long y) {
    while (y != 0) {
        long long t = y;
        y = x % y;
        x = t;
    }
    return x;
}

long long lcm(long long x, long long y) {
    return x / gcd(x, y) * y;
}

int main() {
    freopen("gcm.in", "r", stdin);
    freopen("gcm.out", "w", stdout);
    long long a, b;
    cin >> a >> b;

    if (a > b) {
        long long t = a; a = b; b = t;
    }

    long long d = gcd(a, b);
    long long m = lcm(a, b);

    long long x = a;
    long long y = b;
    vector<int> p;
    for (int v = 0; v < MAX_IT; v++) {
        a++;
        if (m % a == 0 && a % d == 0) {
            p.push_back(a);
        }
    }    
    for (int v = 0; v < MAX_IT; v++) {
        b--;
        if (m % a == 0 && a % d == 0) {
            p.push_back(b);
        }
    }    

    sort(p.begin(), p.end());

    for (int i = 0; i < p.size(); i++) {
        for (int j = i; j < p.size(); j++) {
            a = p[i];
            b = p[j];
            if (y - x > b - a && gcd(a, b) == d && lcm(a, b) == m) {
                x = a;
                y = b;
            }
        }
    }

    cout << x << " " << y << endl;

    return 0;             
}                          
