import Control.Applicative

fill a t ai ti = head [ (a',t') | x<-[ start..]
                                , let a'=x*ai
                                      t'=x*ti
                                , a'>=a
                                , t'>=t
                                ]
              where start = max (a`div`ai) (t`div`ti)

solve [] (a,t) = a+t
solve ([ai,ti]:ats) (a,t) = solve ats $ fill a t ai ti

main = do
  _ <- read <$> getLine :: IO Int
  ats <- map (map read.words).lines <$> getContents :: IO [[Integer]]
  print $ solve ats (1,1)
