a = int(input()) b = ["b","2","8"] c = ["c","3","9"] d = ["d","7","9"] i = "b" j = "c" k = "d" for i in range(a): e,f,g,h = map(str,input().split()) if b == [i,e,f]: b = [i,g,h] elif c == [j,e,f]: c = [j,g,h] elif d == [k,e,f]: d = [k,g,h] if b == ["b","5","8"] and c == ["c","4","8"] and d == ["d","6","8"]: print("YES") else: print("NO")