N = int(input()) L = [list(map(int,input().split())) for i in range(N)] a = [2,8] b = [3,9] c = [7,9] for k in L : l = k[:2] l2 = k[2:] if a == l : a = l2 elif b == l : b = l2 elif c == l : c = l2 if a == [5,8] and b == [4,8] and c == [6,8] : print("YES") else : print("NO")