#!/bin/python3 import sys n = int(input().strip()) s_x = 1 s_y = 1 li_x = [] li_y = [] for a0 in range(n): x,y = input().strip().split(' ') x,y = [int(x),int(y)] li_x.append(x) li_y.append(y) for i in range(1,n): if li_x[i] != li_x[i-1]: s_x = 0 if li_y[i] != li_y[i-1]: s_y = 0 if s_y == 1 or s_x == 1: print("YES") else: print("NO")