let solve (mt, ma) (t, a) =
    let rec solve' (mult:uint64) :uint64 * uint64 =
        let nextT, nextA = (t * mult, a * mult)
        if nextT >= mt && nextA >= ma then (nextT, nextA)
        else solve' (mult + 1UL)
    solve' 1UL

let () =
    let n = stdin.ReadLine  () |> int

    let taSeq =
        seq { for i in 1..n do
                let t, a =
                    stdin.ReadLine () |>
                    (fun line -> line.Split()) |>
                    (fun arr -> (uint64 arr.[0], uint64 arr.[1]))
                yield (t, a)}

    Seq.fold solve (0UL, 0UL) taSeq |>
    (fun (t, a) -> t + a) |>
    printfn "%d"