Go: package main

import "fmt"

func GCM(a, b int) int {
	if a < b {
		a, b = b, a
	}
	if b == 0 {
		return a
	}
	return GCM(b, a % b)
}

func LCM(a, b int) int {
	return a*b/GCM(a, b)
}

func main() {

	for {
		var a, b int
		var G, L int
		fmt.Scanf("%d %d", &a, &b)
		if a == 0 {
			break
		}
		G = GCM(a, b)
		L = LCM(a, b)
		fmt.Printf("%d %d\n", G, L)
	}
}

C++: #include<iostream>
#include<algorithm>
#include<stdio.h>
using namespace std;
int main(){
    long long a,b,i,f,j;
    while(cin>>a>>b){
    for(i=15000000;i>0;i--){
        if(a>=2000000000||b>=2000000000||a<1||b<1){
            break;
        }
        if(a%i==0&&b%i==0){
            f=a*b/i;
            cout<<i<<" "<<f<<endl;
                break;
        }
    }
    }
    return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cstdlib>

using namespace std;

long long gcd(long long a,long long b)
{
    return !b ? a : gcd(b, a%b);
}

long long lcm(long long a,long long b)
{
    long long d = gcd(a,b);
    return (a/d)*b;
}

int main()
{
    long long a,b;
    while(scanf("%lld %lld",&a,&b) != EOF)
    {
        printf("%lld %lld\n",gcd(a,b),lcm(a,b));
    }
    return 0;
}

C++: #include <iostream>
using namespace std;

long long int gcd(long long int a, long long int b) {
    if (a % b == 0) return b;
    return gcd(b, a % b);
}

int main() {
    long long int a, b;
    while(cin >> a) {
        cin >> b;
        cout << gcd(a, b) << " " << a / gcd(a, b) * b << endl;
    }
    return 0;
}

C++: #include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<string>
using namespace std;

int main() {
	
	int a, b;
	int lcm, gcd;
	for (;;) {
		cin >> a >> b;
		int i = 2;
		lcm = 1;
		while (i <= a && i <= b) {
			if (a % i == 0 && b % i == 0) {
				lcm *= i;
				a /= i;
				b /= i;
			}
			else i++;
		}
		printf("%d %d\n", lcm, a * b * lcm);
	}

	//system("pause");
	return 0;
}

C++: #include<iostream>
using namespace std;

//最大公約数
int gcd(int a, int b)
{
    int r;
    while((r = a % b) != 0) 
    {
        a = b;
        b = r;
    }
    return b;
}


//最小公倍数
nt lcm(int a, int b)
{
    return (a * b / gcd(a,b));
}



int main(){

int a,b;

while(cin >> a >> b){
    if(a == -1 or b == -1)  break;
   while(a <= 0 or b <= 0){
       cin >> a >> b;
   }
   if(a > 0 and b > 0){
        cout << gcd(a,b) << lcm(a,b);
    }
}

return 0;
}

C++: #include <iostream> 
#include<string.h>
#include<stdio.h>
using namespace std;
long long cc( long  long  q, long long  p)
{

	if(q%p==0)
	{
		return p;
	}
	else
	return cc(p,q%p);
}
main()
{
	long long x,y,a[1000],b[1000];
	int i=0;
	while(scanf("%lld%lld",&x,&y)!=EOF)
	{
	  
		 a[i]=cc(x,y);
		 b[i]=x*y/a[i];
	     i++;	
	     
	    
	}
	for(int j=0;j<i;j++)
	{
		printf("%lld %lld\n",a[j],b[j]);
	}
}

C++: #include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <cstring>
using namespace std;
typedef long long int ll;
const int INF = 1000000000;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b){
    // a >= b
    for(ll i = a; i <= (b * a); i += a){
        if(i % b == 0) return i;
    }
}
int main(){
    for(ll a, b; cin >> a >> b;){
        cout << gcd(a, b) << " ";
        if(a > b){
            cout << lcm(a, b) << endl;
        }else{
            cout << lcm(b, a) << endl;
        }
    }
    return 0;
}

C++: #include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

int main()
{
	long long a,b;
	long long GCD=0,LCM=0;
	long long tmp=0,tmp_a,tmp_b;

	
	while (cin >> a >> b)
	{
		tmp_a = a;
		tmp_b = b;
		tmp = a%b;
		while (tmp!=0) {
			a = b;
			b = tmp;
			tmp = a%b;
		}
		GCD = b;

		LCM = tmp_a*tmp_b / GCD;

		cout << GCD <<" "<<LCM<<endl;
	}

	return 0;
}

C++: #include<stdio.h>
int main(){
  long a,b,m,l;
  while(scanf("%d %d",&a,&b)!=EOF){
    m = a%b;
    l = a*b;
    while(m){
      a = b;
      b = m;
      m = a%b;
    }
    printf("%d %d\n",b,l/b);
  }
}

C++: #include <iostream>
#include <iomanip>
using namespace std;

double eucAlg(int a,int b);


int main(int argc, char* argv[])
{
	double a,b;	//??\??????
	double c, d;	//??????

	cin >> a >> b ;
	
	c = eucAlg(a, b);

	d = a * b / c;
	cout << fixed << setprecision(0) << c << " " << d << endl;

	return 0;
}

//??????????????????????????????
double eucAlg(
	int a,
	int b
	)
{
	double c;

	do
	{
		c = a % b;
		if(c == 0){
			break;
		}
		a = b;
		b = c;

	}while(1);

	return b;
}

C++: #include <iostream>
int gcd(int a, int b) {
	return (a ? gcd(b % a, a) : b);
}
int main() {
	int a, b, x;
	while (std::cin >> a >> b) {
		x = gcd(a, b);
		std::cout << x << " " << a / x * b << std::endl;
	}
}

C++: #include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;

int main(){
	int a, b, min ,max, gcd, lcm;
	
	while(cin >> a >> b){
		
		min = min(a, b);
		max = max(a, b);
		
		for(int i = 0; i < min; i++){
			if(min % i == 0 && max % i == 0) gcd = i;
		}
		
		while(1){
			int i = 1;
			if( (max * i) % min == 0) {
				lcm = max *i;
				break;
			}
			else i++;
		}
	}	
		cout << gcd <<  " " << lcm << endl;
}

C++: #include <iostream>
#include "cstdio"
using namespace std; 

int main() 
{    int a,b,m,n,r,t;
   
  while(scanf("%d%d",&a,&b)!=EOF)
{  
	if(a<b)
	{    t=b;
	     b=a;
		 a=t;
	}
	m=a;
	n=b;
	while((r=a%b)!=0)
	{   a=b;
	    b=r;
	}
	cout<<b<<" "<<m/b*n<<endl;

	
}
	return 0;
}

C++: #include <iostream>
using namespace std;
int GCD(int a,int b)
{
	if (a%b==0)
		return b;
	else
		return GCD(b,a%b);
}
int cmp(const void *a,const void *b)
{
	return *(int*)b-*(int*)a;
}
int main()
{
	int a[2],gcd,lcm;
	while(cin>>a[0]>>a[1])
	{
		if (cin.eof())break;
		qsort(a,2,sizeof(int),cmp);
		gcd=GCD(a[0],a[1]);
		lcm=(a[0]*a[1])/gcd;
		cout<<gcd<<' '<<lcm<<endl;
	}
	return 0;
}

C++: #include <iostream>
using namespace std;

int main() {
	// your code goes here
	long long a;
	long long b;
	long long r;
	long long gcd;
	long long lcm;
	while(cin>>a>>b){
		
		long long c=a;
		long long d=b;
		while(true){
		r=c%d;
		if(r==0){gcd=d; break;}
		c=d; d=r;
		
		}

	lcm= a*b / gcd;
	
	
	cout << gcd << " " << lcm << endl;	
	}
	return 0;
	
	
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int a, b;
	while (cin >> a >> b){
		int gcd;
		int aa = max(a, b);
		int bb = min(a, b);
		while (true){
			if (aa % bb == 0) {
				gcd = bb;
				cout << gcd << ' ';
				goto C;
			}
			else{
				int tmp = aa - bb;
				aa = bb;
				bb = tmp;
			}
		}
	C:
		cout << a*b / gcd << endl;
	}
}

C++: #include<cstdio>
int g(int a,int b){return b?g(b,a%b):a;}
main(){int a,b;while(~scanf("%d%d",&a,&b))printf("%d %d\n",g(a,b),a/g(a,b)*b);}

C++: #include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int main(){
	long long a,b;
	while(cin>>a>>b){
	long long ta=a,tb=b;
	long long s=0,m=0;
	if(a<b)swap(a,b);
	while(true){
		int tmp=a;
		a=b;
		b=tmp%a;
		if(a%b==0){
			m=b;
			break;
		}
		if(a<b){
		//cout<<a<<" "<<b<<endl;
		m=1;
		break;
		}
	}
		s=(ta*tb)/m;
		cout<<m<<" "<<s<<endl;
	}
}

C++: #include<stdio.h>
#include<math.h>
 
int main(){
    unsigned int a,b;
    while(~scanf("%u%u",&a,&b)){
        unsigned int c=a,d=b;
        while(a>0&&b>0){
            if(a>b)a=a%b;
            else b=b%a;
        }
        printf("%u %u\n",a+b,c/(a+b)*d);
    }
}

C++: #include <iostream>

using namespace std;

void solve(long long a, long long b) {
	long long num = a * b;
	while (a != b) {
		if (a > b) {
			a -= b;
		}else if(b > a){
			b -= a;
		}

		if (a == b) {
			break;
		}
	}
	cout << a << " " << num / a << endl;
}

int main() {
	long long a, b;
	while (cin >> a >> b) {
		solve(a, b);
	}
	return 0;
}