import Data.Function     (on)
import Data.Ratio
import Data.Strict.Tuple

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 (a % x) (b % y) (x :!: y) rs
    go p q = (.) inner $ bimap <*> id $ (on max ceiling p q *)

bimap :: (a -> c) -> (b -> d) -> Pair a b -> Pair c d
bimap f g (x :!: y) = f x :!: g y
