main = do
    [n] <- getInt <$> getLine
    ta <- getIntLines n
    putStrLn $ show n
    putStrLn $ show ta
    putStrLn $ show $ answer ta
    
getInt :: String -> [Int]
getInt = map read . words

getIntLines :: Int -> IO [[Int]]
getIntLines n = sequence $ take n $ repeat $ getInt <$> getLine

answer :: [[Int]] -> Int
answer (ta:tas) = sum $ foldl foldfunc ta tas

foldfunc :: [Int] -> [Int] -> [Int]
foldfunc [at,aa] [t,a] = let alp = max (ceildiv at t) (ceildiv aa a)
                         in [alp * t, alp * a]

ceildiv :: Int -> Int -> Int
ceildiv x y = x `div` y + (if x `mod` y == 0 then 0 else 1)
