main = do
  getLine
  tas <- map (map read . words) . lines <$> getContents
  print (report tas)
 
report :: [[Integer]] -> Integer
report ([t,a]:tas) = uncurry (+) (foldl asum (t,a) tas)
 
asum (at,aa) [t,a] = let n = max (idiv at t) (idiv aa a) in (n*t, n*a)
 
idiv x y = ceiling $ (fromIntegral x) / (fromIntegral y)
