#include
using namespace std;
int main() {
int t;
scanf("%d",&t);
while(t–){
int a,b;
scanf("%d %d",&a,&b);
int hf;
long long lc=(long long)a*b;
while(b!=0){
int t=b;
b=a%b;
a=t;
}
hf=a;
lc=(lc/hf);
cout<<hf<<" "<<lc;
}
return 0;
}