#!/bin/ruby n = gets.strip.to_i min = -100 i = j = min onX = onY = true n.times do x, y = gets.strip.split(' ').map(&:to_i) onX = false if (i > min && x != i) onY = false if (j > min && y != j) i = x j = y end if onX || onY puts "YES" else puts "NO" end