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 pre_x= in.nextInt(); int pre_y=in.nextInt(); int x_cnt=0; int y_cnt=0; for(int a0 = 1; a0 < n; a0++){ int x = in.nextInt(); int y = in.nextInt(); if(x!=pre_x){ x_cnt++; } if(y!=pre_y){ y_cnt++; } pre_x=x; pre_y=y; } if(x_cnt >0 && y_cnt>0){ System.out.println("NO"); } else{ System.out.println("YES"); } } }