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)

while data =gets
	if data == nil
		break
	end
x=1
y=1
z=1
gcd=[]
gcda=[]
gcdb=[]

lcma=[]
lcmb=[]

	a,b=data.split(" ").map{|num| num.to_i}
	i=2
	while i <= a || i <= b
		if a%i==0 && b%i==0
#		p "a=#{a} b=#{b} i=#{i}  ab??????"
			gcd << i
			a = a/i
			b = b/i
			redo
		elsif a%i==0
#		p "a=#{a} b=#{b} i=#{i}  a??????"
			gcda << i
			a = a/i
			redo
		elsif b%i==0
#		p "a=#{a} b=#{b} i=#{i}  b??????"
			gcdb << i
			b = b/i
			redo
		end
		i+=1
#		p "#{a} #{b}"
	end

	gcda.each do |i|
		x=x*i 
	end

	gcdb.each do |i|
		y=y*i 
	end

	gcd.each do |i|
		z=z*i 
	end

	#puts "#{gcd} #{x} #{y} #{z} #{x*y*z}"
	puts "#{z} #{x*y*z}"

end