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