import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed as VU
import Data.Char

toTuple bs =
    let
        Just (a, bs') = B.readInt bs
        Just (b, _) = B.readInt $ B.dropWhile isSpace bs'
    in
        (a, b)

solve xys = let (a, b) = VU.foldl' step (1, 1) xys in a + b 
    where
        step (a, b) (x, y) = (m*x, m*y)
            where
                h i j = let (q, r) = quotRem i j in if r == 0 then q else q + 1
                qr = h a x
                st = h b y 
                m = max qr st

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