#!/bin/python import sys n = int(raw_input().strip()) count = 0 is_x = False is_y = False for a0 in xrange(n): x,y = raw_input().strip().split(' ') x,y = [int(x),int(y)] if count == 0: ex = x why = y else: prev_x = ex prev_y = why why = y ex = x if prev_x == ex and prev_y != why and is_y is False: is_x = True elif prev_y == why and prev_x != ex and is_x is False: is_y = True else: is_x = False is_y = False print 'NO' break count += 1 if is_x or is_y: print 'YES'