#!/bin/python3 import sys from collections import Counter n = int(input().strip()) cx, cy = Counter(), Counter() for a0 in range(n): x,y = input().strip().split(' ') x,y = [int(x),int(y)] cx[x] += 1 cy[y] += 1 if len(cx) == 1 or len(cy) ==1: print('YES') else: print('NO')