import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt();int temp1=0,temp2=0,count1=0,count2=0,a0; for( a0 = 0; a0 < n; a0++){ int x = in.nextInt(); int y = in.nextInt(); if(a0==0) { temp1=x;temp2=y; } else { if(temp1==x) count1++; if(temp2==y) count2++; } } if(count1!=n-1&&count2!=n-1) System.out.println("NO"); else System.out.println("YES"); } }