#!/bin/python3 import sys n = int(input().strip()) hori, verti = True, True h, v = None, None while n > 0: x, y = list(map(int, input().split())) if h == None: h = x v = y else: if x != h: hori = False if y != v: verti = False n -= 1 if hori or verti: print("YES") else: print("NO")