n=int(input()) s=[2,8,3,9,7,9] for i in range(n): a,b,c,d=map(int,input().split()) if s[0]==a and s[1]==b: s[0]=c s[1]=d elif s[2]==a and s[3]==b: s[2]=c s[3]=d elif s[4]==a and s[5]==b: s[4]=c s[5]=d if s == [5,8,4,8,6,8]: print("YES") else: print("NO")