import Data.Bool  (bool)
import Data.Ratio

import Control.Monad

main :: IO ()
main = do
    n  <- read <$> getLine
    rs <- replicateM n getPair
    print $ solve rs

getPair = (\(x:y:_) -> (x, y)) . fmap read . words <$> getLine

solve :: [(Int, Int)] -> Int
solve = inner (1, 1)
  where
    inner (a, b)           []  = a + b
    inner (a, b) ((x, y) : rs)
      | a <= x && b <= y = inner (x, y) rs
      | a %  x >  b %  y = go (a, b) (x, y) False rs
      | a %  x <  b %  y = go (b, a) (y, x) True  rs
      | otherwise        = inner (a, b) rs

    go (p, _) (u, v) = inner . bool (n, m) (m, n)
      where
        r = ceiling $ p % u
        n = u * r
        m = v * r
