n = int(input()) s = [(2,8), (3,9), (7,9)] ans = [(5,8), (4,8), (6,8)] for _ in range(n): x1,y1,x2,y2 = map(int,input().split()) if not (x1,y1) in s: continue ns = [] for x,y in s: if x==x1 and y==y1: ns.append((x2,y2)) else: ns.append((x,y)) s = ns print('YES' if s==ans else 'NO')