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