#include<iostream>
int a,b,c,d,s;int e(){if(a<b)a^=b^=a^=b;return(a%=b)?e():b;}int f(){if(a<b)a^=b^=a^=b;for(;a>b;)b+=d;return a-b?f():a;}int main(){for(;s=!(std::cin>>a>>b).eof();s&&printf("%d %d\n",e(),(c=a,d=b,f())));}