#yuki870

n=int(raw_input())
ls=[(2,8),(3,9),(7,9)]
lg=[(5,8),(4,8),(6,8)]
for i in xrange(n):
 x0,y0,x1,y1=map(int,raw_input().split())
 if (x0,y0) in ls:
  temp=ls.index((x0,y0))
  ls[temp]=(x1,y1)
if ls==lg:
 print 'YES'
else:
 print 'NO'