#!/bin/python3 import sys n = int(input().strip()) countx = {} county = {} for a0 in range(n): x,y = input().strip().split(' ') x,y = [int(x),int(y)] countx[x] = 1 county[y] = 1 if len(countx) > 1 and len(county) > 1: print("NO") else: print("YES")