#!/bin/python import sys h = True v = True n = int(raw_input().strip()) for a0 in xrange(n): x,y = raw_input().strip().split(' ') if a0!=0: if x!=xprev: v = False if y!=yprev: h = False if not v and not h: break xprev = x yprev = y print "YES" if v or h else "NO"