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++){ x[a0] = in.nextInt(); y[a0] = in.nextInt(); } int cntx = 0; int cnty = 0; for(int i=1; i < n; i++){ if (x[0] == x[i]){ cntx++; } if (y[0] == y[i]){ cnty++; } } if (cntx == n-1 || cnty == n-1){ System.out.println("YES"); } else{ System.out.println("NO"); } } }