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[] X = new int[n]; int[] Y = new int[n]; for(int a0 = 0; a0 < n; a0++){ int x = in.nextInt(); int y = in.nextInt(); X[a0]=x; Y[a0]=y; } int first=X[0]; int second=Y[0]; int count=0; int ycount=0; for (int element : X) { if (element != first) { for (int element2 : Y){ if (element != first) { System.out.println("NO"); break; } else{ ycount++; } } } else { count++; } } if(count==n){ System.out.println("YES"); } else if(ycount==n){ System.out.println("YES"); } } }