n = gets.to_i x, y = [], [] (1..n).each do |i| xi, yi = gets.split.map(&:to_i) x << xi y << yi end if x.uniq.length == 1 or y.uniq.length == 1 puts "YES" else puts "NO" end