module Main where

import           Control.Monad
import           Data.List
import Prelude


main = do
  n  <- read <$> getLine
  rs <- replicateM n getPair
  print $ solve rs

getPair = (\(x : y : _) -> (x, y)) . fmap read . words <$> getLine

solve :: [(Int, Int)] -> Int
solve xs = uncurry (+) $ foldl' getNextVotes (1, 1) xs


-- 現在の投票数と次の投票数の比から、次の投票数を返却する
getNextVotes ::  (Int, Int) -> (Int, Int) -> (Int, Int)
getNextVotes (a, b) (x, y) =  (n * x,  n * y) where
  n = max (a `ceilDiv` x) (b `ceilDiv` y)

ceilDiv :: Int -> Int -> Int
ceilDiv x y = x `div` y + (if x `mod` y == 0 then 0 else 1)
