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 xx = -1; int yy = -1; boolean horiz = true; boolean vert = true; for(int a0 = 0; a0 < n; a0++){ int x = in.nextInt(); int y = in.nextInt(); if (a0 != 0 && xx != x) { horiz = false; } if (a0 != 0 && yy != y) { vert = false; } xx = x; yy = y; } if (horiz || vert) { System.out.println("YES"); } else { System.out.println("NO"); } } }