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 tests = in.nextInt(); int[] x = new int[tests]; int[] y = new int[tests]; for (int i = 0; i < tests; i++) { x[i] = in.nextInt(); y[i] = in.nextInt(); } if (sameElements(x) == true || sameElements(y) == true) { System.out.println("YES"); } else { System.out.println("NO"); } } public static boolean sameElements(int[] array) { if (array.length == 0) { return true; } else { int first = array[0]; for (int element : array) { if (element != first) { return false; } } return true; } } }