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 lire=new Scanner(System.in); int n=lire.nextInt(); int x[]=new int[n]; int y[]=new int[n]; for (int i = 0; i < n; i++) { x[i]=lire.nextInt(); y[i]=lire.nextInt(); } if(find(x) || find(y))System.out.println("YES"); else System.out.println("NO"); } static boolean find(int x[]){ int a=x[0]; for (int i = 0; i < x.length; i++) { if(x[i]!=a)return false; } return true; } }