main = do
  getLine
  tas <- map (map read . words) . lines <$> getContents
  print (report tas)

report = uncurry (+) . foldl asum (1,1)

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)