open Printf
open Scanf

let input_string () =
  scanf "%s\n" (fun s -> s)

let input_int () =
  scanf "%d\n" (fun k -> k)

let input_int2 () =
  scanf "%d %d\n" (fun x y -> (x, y))

let input () =
  let n = input_int () in
  let rec loop acc i =
    if i = n then
      (n, List.rev acc)
    else
      let (a, b) = input_int2 () in
      loop ((a, b)::acc) (i+1)
  in
  loop [] 0

let f () =
  let (n, ps) = input () in
  let rec loop ps =
    match ps with
     | (a1, b1)::(a2, b2)::(a3, b3)::ps' ->
        if a1=b1 && a2=b2 && a3=b3 then
          true
        else
          loop ((a2, b2)::(a3, b3)::ps')
     | _ -> false
  in
  if loop ps then
    printf "Yes\n"
  else
    printf "No\n"

let () = f ()
