#include<iostream>
using namespace std;

double gcd(double m,double n);
double lcm(double m,double n);

int main(){
	int i;
	double a,b;
	double z[10] ={0} ;
	double y[10] = {0} ;


	for(i=0;i<4;i+=2){
		while(1){
			cin >> a >> b ;
			z[i] = a ;
			z[i+1] = b ;

			if((z[i] <= 200000000) && (z[i] > 0 )){
				if((z[i+1] <= 2000000000) && (z[i+1] > 0)) break;
			}
		}


	}

	y[0] = gcd(z[0],z[1]) ;
	y[1] = lcm(z[0],z[1]) ;
	y[2] = gcd(z[2],z[3]) ;
	y[3] = lcm(z[2],z[3]) ;

	cout << y[0] << " "<< y[1] << "\n" ;
	cout << y[2] << " " << y[3] << endl ;
	return 0;
}

	double gcd( double m, double n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	// ユークリッドの方法
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}

double lcm( double m, double n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}