import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    int[][] dice = new int[N][2];
    for(int i = 0; i < N; i++){
      dice[i][0] = scan.nextInt();
      dice[i][1] = scan.nextInt();
    }
    
    int count = 0;
    String judge = "No";
    for(int[] roll: dice){
      if(roll[0] != roll[1]){
        count = 0;
      } else {
        count += 1;
      }
      
      if(count == 3){
        judge = "Yes";
        break;
      }
    }
    
    System.out.println(judge);	
  }
} import java.util.*; util.* java public class Main {
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    int[][] dice = new int[N][2];
    for(int i = 0; i < N; i++){
      dice[i][0] = scan.nextInt();
      dice[i][1] = scan.nextInt();
    }
    
    int count = 0;
    String judge = "No";
    for(int[] roll: dice){
      if(roll[0] != roll[1]){
        count = 0;
      } else {
        count += 1;
      }
      
      if(count == 3){
        judge = "Yes";
        break;
      }
    }
    
    System.out.println(judge);	
  }
} Main public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    int[][] dice = new int[N][2];
    for(int i = 0; i < N; i++){
      dice[i][0] = scan.nextInt();
      dice[i][1] = scan.nextInt();
    }
    
    int count = 0;
    String judge = "No";
    for(int[] roll: dice){
      if(roll[0] != roll[1]){
        count = 0;
      } else {
        count += 1;
      }
      
      if(count == 3){
        judge = "Yes";
        break;
      }
    }
    
    System.out.println(judge);	
  } main {
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    int[][] dice = new int[N][2];
    for(int i = 0; i < N; i++){
      dice[i][0] = scan.nextInt();
      dice[i][1] = scan.nextInt();
    }
    
    int count = 0;
    String judge = "No";
    for(int[] roll: dice){
      if(roll[0] != roll[1]){
        count = 0;
      } else {
        count += 1;
      }
      
      if(count == 3){
        judge = "Yes";
        break;
      }
    }
    
    System.out.println(judge);	
  } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int N = scan.nextInt(); N scan.nextInt() scan.nextInt scan int[][] dice = new int[N][2]; dice new int[N][2] N 2 for(int i = 0; i < N; i++){
      dice[i][0] = scan.nextInt();
      dice[i][1] = scan.nextInt();
    } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
      dice[i][0] = scan.nextInt();
      dice[i][1] = scan.nextInt();
    } {
      dice[i][0] = scan.nextInt();
      dice[i][1] = scan.nextInt();
    } dice[i][0] = scan.nextInt() dice[i][0] dice[i] dice i 0 scan.nextInt() scan.nextInt scan dice[i][1] = scan.nextInt() dice[i][1] dice[i] dice i 1 scan.nextInt() scan.nextInt scan int count = 0; count 0 String judge = "No"; judge "No" for(int[] roll: dice){
      if(roll[0] != roll[1]){
        count = 0;
      } else {
        count += 1;
      }
      
      if(count == 3){
        judge = "Yes";
        break;
      }
    } int[] roll dice {
      if(roll[0] != roll[1]){
        count = 0;
      } else {
        count += 1;
      }
      
      if(count == 3){
        judge = "Yes";
        break;
      }
    } {
      if(roll[0] != roll[1]){
        count = 0;
      } else {
        count += 1;
      }
      
      if(count == 3){
        judge = "Yes";
        break;
      }
    } if(roll[0] != roll[1]){
        count = 0;
      } else {
        count += 1;
      } roll[0] != roll[1] roll[0] roll 0 roll[1] roll 1 {
        count = 0;
      } count = 0 count 0 {
        count += 1;
      } count += 1 count 1 if(count == 3){
        judge = "Yes";
        break;
      } count == 3 count 3 {
        judge = "Yes";
        break;
      } judge = "Yes" judge "Yes" break; System.out.println(judge) System.out.println System.out System System.out judge String[] args args public class Main {
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    int[][] dice = new int[N][2];
    for(int i = 0; i < N; i++){
      dice[i][0] = scan.nextInt();
      dice[i][1] = scan.nextInt();
    }
    
    int count = 0;
    String judge = "No";
    for(int[] roll: dice){
      if(roll[0] != roll[1]){
        count = 0;
      } else {
        count += 1;
      }
      
      if(count == 3){
        judge = "Yes";
        break;
      }
    }
    
    System.out.println(judge);	
  }
} public class Main {
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    int[][] dice = new int[N][2];
    for(int i = 0; i < N; i++){
      dice[i][0] = scan.nextInt();
      dice[i][1] = scan.nextInt();
    }
    
    int count = 0;
    String judge = "No";
    for(int[] roll: dice){
      if(roll[0] != roll[1]){
        count = 0;
      } else {
        count += 1;
      }
      
      if(count == 3){
        judge = "Yes";
        break;
      }
    }
    
    System.out.println(judge);	
  }
} Main
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    int[][] dice = new int[N][2];
    for(int i = 0; i < N; i++){
      dice[i][0] = scan.nextInt();
      dice[i][1] = scan.nextInt();
    }
    
    int count = 0;
    String judge = "No";
    for(int[] roll: dice){
      if(roll[0] != roll[1]){
        count = 0;
      } else {
        count += 1;
      }
      
      if(count == 3){
        judge = "Yes";
        break;
      }
    }
    
    System.out.println(judge);	
  }
}