{-# LANGUAGE BangPatterns #-}

import           Control.Monad
import qualified Data.ByteString.Char8 as B
import           Data.Char
import           Data.List

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

readInts :: IO [Int]
readInts = unfoldr (B.readInt . B.dropWhile isSpace) <$> B.getLine

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) [1..]