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 arr[] = new int[n*2]; for(int a0 = 0; a0 < n*2; a0++){ int x = in.nextInt(); arr[a0]=x; } boolean flag=false; boolean flag1=false; for(int j=0;j<=n*2-4;j+=2){ if(arr[j]==arr[j+2]){ flag=true; } else{ flag=false; break; } } for(int j=1;j<=n*2-3;j+=2){ if(arr[j]==arr[j+2]){ flag1=true; } else{ flag1=false; break; } } if(flag|| flag1){ System.out.println("YES"); } else{ System.out.println("NO"); } } }