import Control.Monad
import Data.List

main :: IO()
main = do
    n <- readLn
    ls <- replicateM n (map read . words <$> getLine)
    print $ getsolve (head (head ls)) (last (head ls)) (tail ls)

getsolve :: Integer -> Integer -> [[Integer]] -> Integer
getsolve tpoint apoint ls
    | ls == []								= tpoint + apoint
    | tpoint <= nextT && apoint <= nextA	= getsolve nextT nextA (tail ls)
    | otherwise								= getsolve (nextMult * nextT) (nextMult * nextA) (tail ls)
    where nextT = head (head ls)
          nextA = last (head ls)
          tMult = kiriageDiv tpoint nextT
          aMult = kiriageDiv apoint nextA
          nextMult = max tMult aMult
    

kiriageDiv :: Integer -> Integer -> Integer
kiriageDiv a b
    | mod a b == 0				= div a b
    | otherwise					= 1 + div a b

