#!/bin/python3 import sys n = int(input().strip()) a,b = input().strip().split(' ') a,b = [int(a),int(b)] p,o = True,True for a0 in range(n-1): x,y = input().strip().split(' ') x,y = [int(x),int(y)] if (x!=a): p=False if (y!=b): o=False if (p==False and o==False ): break if p or o: print("YES") else: print("NO")