Problem:
GCD and LCM

Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given a and b.

Input

Input consists of several data sets. Each data set contains a and b separated by a single space in a line. The input terminates with EOF.

Constraints

0 < a, b ≤ 2,000,000,000

LCM(a, b) ≤ 2,000,000,000

The number of data sets ≤ 50

Output

For each data set, print GCD and LCM separated by a single space in a line.

Sample Input

8 6
50000000 30000000

Output for the Sample Input

2 24
10000000 150000000

Solution in JAVA (judge verdict: Time Limit Exceeded)

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	static PrintWriter out = new PrintWriter(System.out);

	static void solve() throws IOException {
		String str;
		while ((str = br.readLine()) != null) {
			String[] strs = str.split(" ");
			long a = Long.parseLong(strs[0]);
			long b = Long.parseLong(strs[1]);
			long A = max(a, b);
			long B = min(a, b);
			long ans1 = 1, ans2 = 1;
			long rr = A - B;
			A = max(B, rr);
			B = min(B, rr);
			long r = A - B;
			while (r > 0) {
				rr = r;
				A = max(B, rr);
				B = min(B, rr);
				r = A - B;
			}
			ans1 = rr;
			ans2 = (a * b) / ans1;

			out.println(ans1 + " " + ans2);
			out.flush();
		}
	}

	public static void main(String[] args) throws IOException {
		solve();
	}

	static long max(long a, long b) {
		return a < b ? b : a;
	}

	static long min(long a, long b) {
		return a < b ? a : b;
	}

	static long abs(long a) {
		return a < 0 ? -a : a;
	}

}