#!/bin/python3 import sys n = int(input().strip()) p_x, p_y = None, None status = "" px,py = input().strip().split(' ') px,py = [int(px),int(py)] horiz = None for a0 in range(n-1): x,y = input().strip().split(' ') x,y = [int(x),int(y)] if horiz is None: if x == px: horiz = True elif y == py: horiz = False else: status = "NO" break else: if (horiz and x != px) or (not horiz and y != py): status = "NO" break if status == "": print("YES") else: print("NO")