import Data.Ratio

main = do
  n <- readLn :: IO Int
  dat <- getContents >>= return . map ((\(t:a:_) -> (t,a)) . map read . words) . lines :: IO [(Integer, Integer)]

  print $ (\(a,b) -> a+b) $ foldl solve (1,1) dat

    where
      solve (t,a) (tr,ar) = (n*tr, n*ar)
        where
          t' = ceiling $ t % tr
          a' = ceiling $ a % ar
          n = max t' a'
