import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N = int(readline()) m = map(int,read().split()) data = zip(m,m,m,m) A = (2,8) B = (3,9) C = (7,9) for x1,y1,x2,y2 in data: if A == (x1,y1): A = (x2,y2) if B == (x1,y1): B = (x2,y2) if C == (x1,y1): C = (x2,y2) answer = 'YES' if all((A == (5,8), B == (4,8), C == (6,8))) else 'NO' print(answer)