Scanf.scanf "%d" (fun n ->
    let d = Array.init n (fun _ -> Scanf.scanf " %d %d" (fun a b -> a, b)) in

    let rec loop i =
        let same (a, b) = a = b in
        if i = n then "No" else
            if same d.(i) && same d.(i - 1) && same d.(i - 2) then "Yes" else loop (i + 1)
    in
    loop 2 |> print_endline
)
