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

main :: IO ()
main = do
    n <- read <$> getLine :: IO Int
    ns <- replicateM n (map (fst . fromJust . B.readInt) . B.words <$> B.getLine) :: IO [[Int]]
    let ms = map (\[a,b] -> (a `div` gcd' a b, b `div` gcd' a b)) ns
    print . (\(a,b) -> a+b) $ foldl' (\(a,b) (na, nb)-> f a b na nb) (1,1) ms

gcd' :: Int -> Int -> Int
gcd' a b = head [ x | let c = min a b, x <- [c,c-1..1], mod a x == 0 && mod b x ==0]

f :: Int -> Int -> Int -> Int -> (Int, Int)
f a b na nb = head [(na*i, nb*i)|i<-[max (div a na) (div b nb)..], na*i >= a, nb*i >= b]