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 C# (judge verdict: Time Limit Exceeded)

using System;
namespace csharptest
{
    class Program
    {
        static void Main(string[] args)
        {
            int i = 0;
            int[] a = new int[100];
            int[] b = new int[100];
            while (true)
            { 
                string str = Console.ReadLine();
                if (String.IsNullOrEmpty(str) == false)
                {
                    int l, n, m;
                    string[] s = new string[2];
                    s = str.Split(' ');
                    n = int.Parse(s[0]);
                    m = int.Parse(s[1]);
                    if (n < m)
                    {
                        for (l = 2; l < n/2+1; l++)
                        {
                            if (0 == n % l && 0 == m % l)
                                a[i] = l;
                        }
                    }
                    else
                    {
                        for (l = 2; l < m/2+1; l++)
                        {
                            if (0 == n % l && 0 == m % l)
                                a[i] = l;
                        }
                    }
                    for (l = n + m;;l++)
                    {
                        if (0 == l % n && 0 == l % m)
                        {
                            b[i] = l;
                            break;
                        }
                    }
                    i++;
                    // nullではなく、かつ空文字列でもない
                }
                else
                {
                    break;
                    // null、もしくは空文字列である
                }
            }
            for (int n = 0; n < i; n++)
            {
                Console.WriteLine(a[n] + " " + b[n]);
            }
        }
    }
}