{-# LANGUAGE BangPatterns #-}

import           Control.Monad
import           Data.Char

main :: IO ()
main = do
    n <- readLn
    tas <- replicateM n (map read . words <$> getLine)
    print $ solve tas

solve :: [[Int]] -> Int
solve = go 0 0

go :: Int -> Int -> [[Int]] -> Int
go !n !m []          = n + m
go !n !m ([t,a]:tas) = go (t * k) (a * k) tas
    where 
        k = head $ filter (\k' -> t * k' >= n && a * k' >= m) [k0..]
        k0 = (n `div` t) `max` (m `div` a)
