#include <bits/stdc++.h>
using namespace std;
long long ucln(long long a,long long b)
{
    long long r;
    while (b!=0)
    {
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}
int main()
{
	freopen("DE001"".INP","r",stdin);
	freopen("DE001"".OUT","w",stdout);
    long long a,b,d;
    while (true)
    {
    	cin>>a>>b;
    	if (a==0&&b==0) break;
    	d=ucln(a,b);
    	cout<<a/d<<" "<<b/d;
    	cout<<endl;
	}
}

