#include <iostream>
using namespace std;

int main () {
    int a, b, c, d, e, f, g, l;
    cin >> a >> b;
    c = e = a; d = f = b;
    while(1) {
        if(a>b) {
            a %= b;
            if(b==0) {g =b; break;}
        }
        else if(a<b) {
            b %= a;
            if(a==0) {g= a; break;}
        }
    }
    while(1) {
        if(c>d) d += f;
        else if(c<d) c += e;
        if(c == d) l = c;
    }
    cout << g << " " << l << endl;
}