let () = Scanf.scanf "%d\n" @@ fun n ->
  let tas = Array.init n @@ fun _ -> Scanf.scanf "%d %d\n" @@ fun t a -> t, a in
  let x, y =
    Array.fold_left (fun (x, y) (t, a) ->
      let i = (x + t - 1) / t in
      let j = (y + a - 1) / a in
      (t * max i j, a * max i j)) tas.(0) tas in
  Printf.printf "%d\n" @@ x + y
