main = do getLine a <- map read . words <$> getLine getLine b <- map read . words <$> getLine let bunshi = head a * product [b !! i | i <- [0 .. length b - 1], odd i] let bumbo = product (tail a) * product [b !! i | i <- [0 .. length b - 1], even i] let bunshi_div = bunshi `div` gcd bunshi bumbo * bumbo `div` abs bumbo let bumbo_div = bumbo `div` gcd bunshi bumbo * bumbo `div` abs bumbo putStrLn $ show bunshi_div ++ " " ++ show bumbo_div