#!/bin/python3 import sys n = int(input().strip()) lst = [] for a0 in range(n): x,y = input().strip().split(' ') x,y = [int(x),int(y)] lst.append((x,y)) ans, c, ind = True, 0, 0 if (lst[0][0] == lst[1][0]): c, ind = lst[0][0], 0 elif(lst[0][1] == lst[1][1]): c, ind = lst[0][1], 1 else: ans = False for i in range(2, len(lst)): if (lst[i][ind] != c): ans = False if(ans): print("YES") else: print("NO")