import Control.Monad

main :: IO ()
main = do
  n <- readLn
  tas <- replicateM n $ (\[x,y] -> (x,y)) . map read . words <$> getLine
  let (x,y) = foldl1 solve tas
  print $ x + y

solve :: (Integer,Integer) -> (Integer,Integer) -> (Integer,Integer)
solve (x,y) (t,a) = let x' = fromInteger x
                        y' = fromInteger y
                        t' = fromInteger t
                        a' = fromInteger a
                        f = max (floor $ x'/t') (floor $ y'/a')
                    in (f * t, f * a)
