solve :: [Int] -> [String]
solve (x:y:xs)
  | xs == [] = []
  | otherwise =	(show (gcd x y)	++ " " ++ show (lcm x y)) : solve xs

main = getContents >>= mapM_ putStrLn . solve . (++[1,1]) . map read . words