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

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

template <typename T>
T abs(T x) {
    return x > 0 ? x : -x;
}

int gcd(int a, int b) {
    while (b) { 
        a %= b;
        std::swap(a, b);
    }
    return a;
}

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

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

void factorize(long long number, std::vector <long long> &primes) {
    primes.clear();
    for (long long i = 2; i * i <= number; ++i) {
        int cnt = 0;
        while (!(number % i))
            ++cnt, number /= i;
        if (cnt)
            primes.push_back(power(i, cnt));
    }
    if (number > 1)
        primes.push_back(number);
}                    

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

void go(int pos, std::vector <long long> &primes) {
    if (pos == (int)primes.size()) {
        if (bestAns > abs(x - y)) {
            bestAns = abs(x - y);
            bestX = x;
            bestY = y;
        }
        return;
    }

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

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

int main() {
    freopen("gcm.in", "r", stdin);
    freopen("gcm.out", "w", stdout);
    int a, b;
    scanf("%d%d", &a, &b);

    int d = gcd(a, b);
    std::vector <long long> primes;
    factorize(lcm(a, b) / d, primes);

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

    if (bestX > bestY)
        std::swap(bestX, bestY);
    printf(LLD" "LLD"\n", bestX * d, bestY * d);
    return 0;             
}                          
