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