let step (a, b) (r1, r2) =
  let ta = (a + r1 - 1) / r1 * r1 in
  let tb = ta / r1 * r2 in
  let m = (b + tb - 1) / tb in
  (m * ta, m * tb)
let n = Scanf.scanf "%d" (fun x -> x)
let () =
  Array.init n (fun _ -> Scanf.scanf " %d %d" (fun x y -> x, y))
  |> Array.fold_left step (1, 1)
  |> (fun (a, b) -> Printf.printf "%d\n" (a+b))