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