a = 28 b = 39 c = 79 for _ in range(int(input())): p,q,r,s = map(int,input().split()) x = 10*p+q y = 10*r+s if x == a: a = y elif x == b: b = y elif x == c: c = y if (a,b,c) == (58, 48, 68): print("YES") else: print("NO")