#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  int are;
  int i;
  int cgd,lcm;
  while(1){
    cin >> a >> b;
    if(a == 0 && b == 0)break;
    if(a == b){
      cout << a << " " << a << endl;
      continue;
    }
    if(a > b){
      int temp = b;
      b = a;
      a = temp;
    }
    cgd = 1;
    for(i = 2;i <= a && i < 65536;i++){
      if(a % i == 0 & b % i == 0){
	cgd = i;
      }
    }
    for(i = b;i < 2147483647;i += b){
      if(i % a == 0 && i % b == 0){
	lcm = i;
	break;
      }
    }
    cout << cgd << " " <<  lcm << endl;
  }
}