import Data.Int (Int64)
import Data.List (foldl')

type VoteRatio a = (a, a)

divCeil :: Integral a => a -> a -> a
divCeil a b = flip div b $ a + b - 1

computeMinSum :: Integral a => [VoteRatio a] -> a
computeMinSum = uncurry (+) . foldl' f (1, 1)
    where f (x, y) (t, a) =
            let n = max (divCeil x t) (divCeil y a) in (n * t, n * a)

readInt64 :: String -> Int64
readInt64 = read

main :: IO ()
main = do
    _ <- getLine
    print . computeMinSum . fmap ((\[t, a] -> (t, a)) . fmap readInt64 . words) . lines =<< getContents
