import sequtils, strutils

var
  ps = { 2:8, 3:9, 7:9 }
let
  n = parseInt readLine stdin
for _ in 0 ..< n:
  let
    xs = stdin.readLine.split.map parseInt
    x1 = xs[0]
    y1 = xs[1]
    x2 = xs[2]
    y2 = xs[3]
  for i in 0 .. 2:
    if ps[i] == (x1, y1):
      ps[i] = (x2, y2)

if ps == { 5:8, 4:8, 6:8 }:
  echo "YES"
else:
  echo "NO"