import Data.Bifunctor (bimap)
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) = go (max (a % x) (b % y)) (x, y) rs
    go p = (.) inner $ bimap <*> id $ (ceiling p *)
