
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
int main()
{
	long long a, b;
	while (cin >> a >> b)
	{
		int A, B; 
		int n = a, m = b;
		int q = a, w = b;
		
//			int n = , m = M;
		while (true)
		{
			if (q == 0) { cout << w << " "; break; }
			if (w == 0) { cout << q << " ";  break; }
			if (w > q) { w -= q; }
			else { q -= w; }
		}
		int s = 1;
		while (true)
		{
			if ((s*n) % m == 0)
			{
				break;
			}
			else { s++; }
		}
		//cout << s*n << " ";

		B = n*s;
		cout<< B<<endl;
	}
	return 0;

}