let inf = 1000000000000000001
let step (a, b) (r1, r2) =
  let c1 = begin
    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)
  end in
  let c2 = begin
    let tb = (b + r2 - 1) / r2 * r2 in
    let ta = tb / r2 * r1 in
    let m = (a + ta - 1) / ta in
    (m * ta, m * tb)
  end in
  min c1 c2

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))

