#!/bin/python import sys n = int(raw_input().strip()) xs = [] ys = [] for a0 in xrange(n): x,y = raw_input().strip().split(' ') x,y = [int(x),int(y)] xs.append(x) ys.append(y) if all([x == xs[0] for x in xs]): print "YES" elif all([x == ys[0] for x in ys]): print "YES" else: print "NO"