def sp(l): l = list(map(int, l)) return l[:2], l[2:] n = int(input()) a, b, c = [2, 8], [3, 9], [7, 9] for _ in "_"*n: d, s = sp(input().split()) if d == a: a = s elif d == b: b = s elif d == c: c = s print("YNEOS"[a!=[5, 8] and b!=[4, 8] and c!=[6, 8]::2])