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)

Signal.trap(:INT){
  exit(0)
}

base_arr = Array.new(50000, true)
base_arr[0] = false #
base_arr[1] = false # how to write cooler these.

# make prime array
i = 2
50000.times do
	if base_arr[i] == true
 		for j in (2..50000) do
 			if i*j < 50000
				base_arr[i*j] = false
			else
		 		break 
			end
		end
	end
	i += 1
end

def prime_dec(x, base_arr) 
	#if x is not prime number, x can devide less than root x
	prime_arr = [1]
	#tmp = Math.sqrt(x).to_i
	50000.times do |i|
		#make prime deconposition
		if base_arr[i] == true
			tmp = Math.sqrt(x).to_i
			tmp.times do |j|
				break if x == 1
		
				if (x % i) == 0
					prime_arr.push i
					x /= i
					redo
				end
			end
		end
	end
	prime_arr.push x
	return prime_arr
end
while str = gets
	nums = str.split(" ")
	num0 = nums[0].to_i
	num1 = nums[1].to_i

	arr0 = prime_dec(num0, base_arr)
	arr1 = prime_dec(num1, base_arr)

	gcd = 1
	gcd_arr = arr0 && arr1
	gcd_arr.size.times do |i|
	 gcd *= gcd_arr[i]
	end
	puts "#{gcd} #{num0.lcm(num1)}"
end