L28 = [2, 8] L39 = [3, 9] L79 = [7, 9] for _ in range(int(input())): a, b, c, d = map(int, input().split()) if [a, b] == [L28[0], L28[1]]: L28 = [c, d] if [a, b] == [L39[0], L39[1]]: L39 = [c, d] if [a, b] == [L79[0], L79[1]]: L79 = [c, d] print(['NO', 'YES'][L28 == [5, 8] and L39 == [4, 8] and L79 == [6, 8]])