#include <stdio.h>int main(){ int x,y,i,n,m,p; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d%d",&x,&y); p=x*y; while(y!=0) { m=x%y; x=y; y=m;} printf("%d %d\n",x,p/x); }return 0;}