#!/bin/python import sys n = int(raw_input().strip()) x0,y0 = map(int, raw_input().strip().split(' ')) same_x = 1 same_y = 1 on_hor_or_ver_line = True for i in range(1, n): x,y = map(int, raw_input().strip().split(' ')) if x == x0: same_x += 1 elif y == y0: same_y += 1 else: break if same_x == n or same_y == n: on_hor_or_ver_line = True else: on_hor_or_ver_line = False if on_hor_or_ver_line: print "YES" else: print "NO"