#!/bin/ruby n = gets.strip.to_i points = [] for a0 in (0..n-1) x,y = gets.strip.split(' ') points << [x.to_i,y.to_i] end if points.map {|p| p[0]}.uniq.count == 1 || points.map {|p| p[1]}.uniq.count == 1 puts "YES" else puts "NO" end