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 (div1 at t) (div1 aa a) in (n*t, n*a)

div1 x y = let (q,r) = divMod x y in q + signum r
