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