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: Accepted)

#encoding:utf-8 No.0005 2014.9.29
def lcm(a,b) #最小公倍数を求めるメソッド
 i = 1
 while true
  if (a*i)%b == 0
   break
  end
 i += 1
 end
 return a*i
end

def gcd(a,b) #最大公約数を求めるメソッド
 if a > b
  x,y = a,b
 else
  x,y = b,a
 end
 r = x%y

 until r == 0
  x = y
  y = r
  r = x%y
 end

 return y
end

numbers = []
while gets
 data = $_.split

 2.times do |i|
  data[i] = data[i].to_i
 end

 numbers.push data
end

i = 0
while i < numbers.length
 puts "#{gcd(numbers[i][0],numbers[i][1])} #{lcm(numbers[i][0],numbers[i][1])}"
 i += 1
end