#!/bin/python import sys xs, ys = [], [] n = int(raw_input().strip()) for a0 in xrange(n): x,y = raw_input().strip().split(' ') x,y = [int(x),int(y)] xs.append(x) ys.append(y) is_vertical = reduce(lambda x, y: x and y == xs[0], xs, True) is_horizontal = reduce(lambda x, y: x and y == ys[0], ys, True) print 'YES' if is_vertical or is_horizontal else 'NO'