let () =
  let n = Scanf.scanf "%d " (fun a -> a) in
  let t_a = Array.to_list @@ Array.init n (fun _ -> Scanf.scanf "%d %d " (fun a b -> a,b)) in

  let rec aux cur = function
    | [] -> cur 
    | (t,a) :: tl -> 
      let (rt,ra) = cur in
      if rt <= t && ra <= a 
      then 
        aux (t,a) tl
      else (
        let mul = max 
            (if ra mod a <> 0 then ra/a+1 else ra/a) 
            (if rt mod t <> 0 then rt/t+1 else rt/t) 
        in
        aux (t*mul,a*mul) tl

      )
  in

  let (rt, ra) = aux (0,0) t_a in
  Printf.printf "%d\n" (rt + ra)
