import java.util.*;
class Main {
    static boolean isDoubletPresent(int[] A, int[] B) {
        int count = 0;
        for(int i = 0; i < A.length; i++) {
            if(A[i] == B[i]) {
                count++;
            }
            else {
                count = 0;
            }
            
            if(count >= 3) {
                return true;
            } 
        }
        
        return false;
    }
    public static void main(String args[]) {
      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      int A[] = new int[N];
      int B[] = new int[N];
      
      for(int i = 0; i < N; i++) {
          A[i] = sc.nextInt();
          B[i] = sc.nextInt();
      }
      
      System.out.print(isDoubletPresent(A, B) ? "Yes" : "No");
    }
} import java.util.*; util.* java class Main {
    static boolean isDoubletPresent(int[] A, int[] B) {
        int count = 0;
        for(int i = 0; i < A.length; i++) {
            if(A[i] == B[i]) {
                count++;
            }
            else {
                count = 0;
            }
            
            if(count >= 3) {
                return true;
            } 
        }
        
        return false;
    }
    public static void main(String args[]) {
      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      int A[] = new int[N];
      int B[] = new int[N];
      
      for(int i = 0; i < N; i++) {
          A[i] = sc.nextInt();
          B[i] = sc.nextInt();
      }
      
      System.out.print(isDoubletPresent(A, B) ? "Yes" : "No");
    }
} Main static boolean isDoubletPresent(int[] A, int[] B) {
        int count = 0;
        for(int i = 0; i < A.length; i++) {
            if(A[i] == B[i]) {
                count++;
            }
            else {
                count = 0;
            }
            
            if(count >= 3) {
                return true;
            } 
        }
        
        return false;
    } isDoubletPresent {
        int count = 0;
        for(int i = 0; i < A.length; i++) {
            if(A[i] == B[i]) {
                count++;
            }
            else {
                count = 0;
            }
            
            if(count >= 3) {
                return true;
            } 
        }
        
        return false;
    } int count = 0; count 0 for(int i = 0; i < A.length; i++) {
            if(A[i] == B[i]) {
                count++;
            }
            else {
                count = 0;
            }
            
            if(count >= 3) {
                return true;
            } 
        } int i = 0; int i = 0; i 0 i < A.length i A.length A A.length i++ i++ i {
            if(A[i] == B[i]) {
                count++;
            }
            else {
                count = 0;
            }
            
            if(count >= 3) {
                return true;
            } 
        } {
            if(A[i] == B[i]) {
                count++;
            }
            else {
                count = 0;
            }
            
            if(count >= 3) {
                return true;
            } 
        } if(A[i] == B[i]) {
                count++;
            }
            else {
                count = 0;
            } A[i] == B[i] A[i] A i B[i] B i {
                count++;
            } count++ count {
                count = 0;
            } count = 0 count 0 if(count >= 3) {
                return true;
            } count >= 3 count 3 {
                return true;
            } return true; true return false; false int[] A A int[] B B public static void main(String args[]) {
      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      int A[] = new int[N];
      int B[] = new int[N];
      
      for(int i = 0; i < N; i++) {
          A[i] = sc.nextInt();
          B[i] = sc.nextInt();
      }
      
      System.out.print(isDoubletPresent(A, B) ? "Yes" : "No");
    } main {
      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      int A[] = new int[N];
      int B[] = new int[N];
      
      for(int i = 0; i < N; i++) {
          A[i] = sc.nextInt();
          B[i] = sc.nextInt();
      }
      
      System.out.print(isDoubletPresent(A, B) ? "Yes" : "No");
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int A[] = new int[N]; A new int[N] N int B[] = new int[N]; B new int[N] N for(int i = 0; i < N; i++) {
          A[i] = sc.nextInt();
          B[i] = sc.nextInt();
      } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
          A[i] = sc.nextInt();
          B[i] = sc.nextInt();
      } {
          A[i] = sc.nextInt();
          B[i] = sc.nextInt();
      } A[i] = sc.nextInt() A[i] A i sc.nextInt() sc.nextInt sc B[i] = sc.nextInt() B[i] B i sc.nextInt() sc.nextInt sc System.out.print(isDoubletPresent(A, B) ? "Yes" : "No") System.out.print System.out System System.out isDoubletPresent(A, B) ? "Yes" : "No" isDoubletPresent(A, B) isDoubletPresent A B "Yes" "No" String args[] args
import java.util.*;
class Main {
    static boolean isDoubletPresent(int[] A, int[] B) {
        int count = 0;
        for(int i = 0; i < A.length; i++) {
            if(A[i] == B[i]) {
                count++;
            }
            else {
                count = 0;
            }
            
            if(count >= 3) {
                return true;
            } 
        }
        
        return false;
    }
    public static void main(String args[]) {
      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      int A[] = new int[N];
      int B[] = new int[N];
      
      for(int i = 0; i < N; i++) {
          A[i] = sc.nextInt();
          B[i] = sc.nextInt();
      }
      
      System.out.print(isDoubletPresent(A, B) ? "Yes" : "No");
    }
}