

nget::Int -> IO [(Int,Int)]
nget 0 = return []
nget n = do
    tac<-getLine
    let t:a:[] =  map read (words tac)::[Int]
    rest<-nget (n-1)
    return ((t,a):rest)

main::IO()
main = do
  nc<- getLine
  let n = read nc ::Int
  dat<-nget n
  print (solver dat)


solver::[(Int,Int)]-> Int
solver (x:xs) = let (t,a)= (foldl step x xs) in (t+a)


step::(Int,Int) -> (Int,Int) -> (Int,Int)
step (t_tot,a_tot) (t,a)
      | (t_q > a_q)  = let l =  if t_m==0 then t_q else t_q +1 in (l*t,l*a)
      | (t_q < a_q)  = let l =  if a_m==0 then a_q else a_q +1 in (l*t,l*a)
      | (t_q ==a_q)  = if (t_m==0)&&(a_m==0) then (t_q*t,a_q*a) else ((t_q+1)*t,(a_q+1)*a)
                    where t_q = div t_tot t
                          a_q = div a_tot a
                          t_m = mod t_tot t
                          a_m = mod a_tot a
