#include <bits/stdc++.h>
using namespace std;
#define N 2000000000
int main() {
	long long int a,b;
	while(cin>>a>>b){
		int* ahoge;
		int* bhoge;
		ahoge=(int*)malloc(sizeof(int)*N);
		bhoge=(int*)malloc(sizeof(int)*N);
		long long int i,j;
		for(i=2;a>1;i++){
			if(a%i==0){
				int count=0;
				do{
					a=a/i;
					count++;
				}while(a%i==0);
				ahoge[i]=count;
			}	
		}
		for(j=2;b>1;j++){
			if(b%j==0){
				int count=0;
				do{
					b=b/j;
					count++;
				}while(b%j==0);
				bhoge[j]=count;
			}	
		}
		long long int great,least,k;
		great=1;
		least=1;
		for(k=2;k<min(i,j);k++){
			great=great*pow(k,min(ahoge[k],bhoge[k]));
		}
		for(k=2;k<max(i,j);k++){
			least=least*pow(k,max(ahoge[k],bhoge[k]));
		}
		cout<<great<<" "<<least<<endl;
	}
	return 0;
}