N=int(input()) a,b=map(int,input().strip().split()) f,g=True,True for n in range(N-1): x,y=map(int,input().strip().split()) if a!=x: f=False if b!=y: g=False a,b=x,y if f or g: print("YES") else: print("NO")