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.util.Scanner;


public class Main{
	public static void main(String[] args)
	{
		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNextLine()){
			String[] s = sc.nextLine().split("[\\s]+");
			int a = Integer.parseInt(s[0]);
			int b = Integer.parseInt(s[1]);
			
			int x = gcd(a,b);
			int y = lcm(a,b);
			
			System.out.println(x +" "+ y);
		}
	}
	
	private static int gcd(int m,int n){
		if((m == 0) || (n == 0)) return 0;
		
		while(m != 0){
			if(m > n) m = m -n;
			else n = n - m;
		}
		return m;
	}
	
	private static int lcm(int m,int n){
		if((m == 0) || (n == 0)) return 0;
		return ((m /gcd(m,n) * n));
	}
}