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 verticalCheck=true; boolean horizontalCheck=true; int x = in.nextInt(); int y = in.nextInt(); int a=x; int b=y; for(int a0 = 1; a0 < n; a0++){ if(verticalCheck || horizontalCheck){ x = in.nextInt(); y = in.nextInt(); if (x!=a){ verticalCheck=false; }else if(y!=b){ horizontalCheck=false; } a=x; b=y; }else{ System.out.println("NO"); break; } } if (verticalCheck || horizontalCheck){ System.out.println("YES"); } } }