let rec input n =
		if n = 0
		then []
		else Scanf.scanf "%d %d\n" (fun x y -> (x,y)) :: input (n - 1)

let solve lst =
	let rec solve_loop before lst = match lst with
		| [] -> let(a,b) = before in a + b
		| first :: xs ->
			let (x,y) = first in
			let (a,b) = before in
			let ratio = max ((a-1)/x+1) ((b-1)/y+1) in
				solve_loop (x*ratio,y*ratio) xs
	in
		solve_loop (1,1) (List.rev lst)

let () =
	Scanf.scanf "%d\n" (fun x -> x) |> input |> solve |> Printf.printf "%d"
