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 Ruby (judge verdict: Wrong Answer)

class Array
  def product(ary)
    temp = self.clone
    result = []
    ary.each do |v|
      if temp.include?(v)
        result << temp.delete_at(temp.index(v))
      end
    end
    result
  end
end

# greatest common divisor(最大公約数)
def gcd(i)
  gcd_div = self.prime_div2.product(i.prime_div2)
  gcg_div.inject {|memo, item| memo * item }
end

# least common multiple(最小公倍数)
def lcm(i)
  lcm_div = self.prime_div2 + i.prime_div2
  lcm_div = lcm_div - self.prime_div2.product(i.prime_div2)
  lcm_div.inject {|memo, item| memo * item }
end

# エラトステネスの篩いによる素数列の生成
def eratosthenes(n)
  list = Array.new(n - 1).map.with_index {|i, k| k + 2}
  result = [1]
  while list.last >= result.last**2
    p = list.shift
    result << p
    list.delete_if {|v| v % p == 0 }
  end
  result.shift
  result = result + list
end

# 素因数分解して[2, 2, 2, 3]の様に返す。
def prime_div
  k = self
  c = 0
  result = []
  eratosthenes(n/2).each do |i|
    c = 0
    if k % i == 0
      while k % i == 0
        k = k / i
        result << k
      end
    end
  end
  result
end

while line = gets
  imput = line.chomp.split.map(&:to_i)
  print imput[0].gcd(imput[1]), " ", imput[0].lcm(imput[1])
end