import Control.Applicative
import Control.Monad

main = do
    n <- readLn
    input <- replicateM n $ (\(a:b:_) -> (a,b) ) . map read . words <$> getLine
    print $ (\(a,b) -> a + b) $ foldl1 solve input where
        solve :: (Int, Int) -> (Int, Int) -> (Int, Int)
        solve (a,b) (c,d) = let
            latio = (1+) $ max ((a-1) `div` c) ((b-1) `div` d)
            in (latio * c, latio * d)
