#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;
}
                     
void factorize(int number, std::vector < std::pair <int, int> > &primes) {
    primes.clear();
    for (int i = 2; i * i <= number; ++i) {
        int cnt = 0;
        while (!(number % i))
            ++cnt, number /= i;
        if (cnt)
            primes.push_back(std::make_pair(i, cnt));
    }
    if (number > 1)
        primes.push_back(std::make_pair(number, 1));
}                    

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

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 < std::pair <int, int> > a_primes, b_primes;
    factorize(a / d, a_primes);
    factorize(b / d, b_primes);
    std::sort(a_primes.begin(), a_primes.end());
    std::sort(b_primes.begin(), b_primes.end());
        
    size_t p1 = 0, p2 = 0;                    
    std::vector <long long> primes;
    while (p1 < a_primes.size() && p2 < b_primes.size()) {
        if (a_primes[p1].first < b_primes[p2].first)
            primes.push_back(power(a_primes[p1].first, a_primes[p1].second)), ++p1;
        else
        if (a_primes[p1].first == b_primes[p2].first)
            primes.push_back(power(a_primes[p1].first, a_primes[p1].second + b_primes[p2].second)), ++p1, ++p2;
        else
            primes.push_back(power(b_primes[p2].first, b_primes[p2].second)), ++p2;
    }

    while (p1 < a_primes.size())
        primes.push_back(power(a_primes[p1].first, a_primes[p1].second)), ++p1;
    while (p2 < b_primes.size())
        primes.push_back(power(b_primes[p2].first, b_primes[p2].second)), ++p2;

    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;             
}                          
