N = int(input()) ls = [[2,8],[3,9],[7,9]] for _ in range(N): a,b,c,d = map(int,input().split()) for i in range(3): if ls[i] ==[a,b]: ls[i] = [c,d] if ls == [[5,8],[4,8],[6,8]]: print("YES") else: print("NO")