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(); boolean isVerticale = true; boolean isHorizontal = true; int oldx = 0; int oldy = 0; for(int a0 = 0; a0 < n; a0++){ int x = in.nextInt(); int y = in.nextInt(); if(oldx != x){ isVerticale = false; }else{ oldx = x; } if(oldy != y){ isHorizontal = false; }else{ oldy = y; } } if(isVerticale || isHorizontal){ System.out.println("YES"); }else{ System.out.println("NO"); } } }