import qualified Data.Vector.Unboxed as VU
import Data.Char

toTuple :: [Int] -> (Int, Int)
toTuple [a, b] = (a, b)

solve xys = let (a, b) = VU.foldl step (1, 1) xys in a + b 
    where
        step :: (Int, Int) -> (Int, Int) -> (Int, Int)
        step (a, b) (x, y) = (m*x, m*y)
            where
                qr = let (q, r) = quotRem a x in if r == 0 then q else q + 1
                st = let (s, t) = quotRem b y in if t == 0 then s else s + 1
                m = max qr st

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