import java.util.*;

class Main{
	public static void main(String args[]){
    	Scanner in = new Scanner(System.in);
      
      int n = in.nextInt();
      int ar[][] = new int[n][2];
      int temp = 0;
      boolean status = false;
      for(int i = 0 ; i < n ; i++){
        ar[i][0] = in.nextInt();
        ar[i][1] = in.nextInt();

        if(ar[i][0]==ar[i][1])
          temp++;
        else
          temp = 0;
        if(status == false && temp == 3){
            status = true;
        }
      }

      if(status == true)
        System.out.println("Yes");
      else
        System.out.println("No");
      
    }
} import java.util.*; util.* java class Main{
	public static void main(String args[]){
    	Scanner in = new Scanner(System.in);
      
      int n = in.nextInt();
      int ar[][] = new int[n][2];
      int temp = 0;
      boolean status = false;
      for(int i = 0 ; i < n ; i++){
        ar[i][0] = in.nextInt();
        ar[i][1] = in.nextInt();

        if(ar[i][0]==ar[i][1])
          temp++;
        else
          temp = 0;
        if(status == false && temp == 3){
            status = true;
        }
      }

      if(status == true)
        System.out.println("Yes");
      else
        System.out.println("No");
      
    }
} Main public static void main(String args[]){
    	Scanner in = new Scanner(System.in);
      
      int n = in.nextInt();
      int ar[][] = new int[n][2];
      int temp = 0;
      boolean status = false;
      for(int i = 0 ; i < n ; i++){
        ar[i][0] = in.nextInt();
        ar[i][1] = in.nextInt();

        if(ar[i][0]==ar[i][1])
          temp++;
        else
          temp = 0;
        if(status == false && temp == 3){
            status = true;
        }
      }

      if(status == true)
        System.out.println("Yes");
      else
        System.out.println("No");
      
    } main {
    	Scanner in = new Scanner(System.in);
      
      int n = in.nextInt();
      int ar[][] = new int[n][2];
      int temp = 0;
      boolean status = false;
      for(int i = 0 ; i < n ; i++){
        ar[i][0] = in.nextInt();
        ar[i][1] = in.nextInt();

        if(ar[i][0]==ar[i][1])
          temp++;
        else
          temp = 0;
        if(status == false && temp == 3){
            status = true;
        }
      }

      if(status == true)
        System.out.println("Yes");
      else
        System.out.println("No");
      
    } Scanner in = new Scanner(System.in); in new Scanner(System.in) int n = in.nextInt(); n in.nextInt() in.nextInt in int ar[][] = new int[n][2]; ar new int[n][2] n 2 int temp = 0; temp 0 boolean status = false; status false for(int i = 0 ; i < n ; i++){
        ar[i][0] = in.nextInt();
        ar[i][1] = in.nextInt();

        if(ar[i][0]==ar[i][1])
          temp++;
        else
          temp = 0;
        if(status == false && temp == 3){
            status = true;
        }
      } int i = 0 ; int i = 0 ; i 0 i < n i n i++ i++ i {
        ar[i][0] = in.nextInt();
        ar[i][1] = in.nextInt();

        if(ar[i][0]==ar[i][1])
          temp++;
        else
          temp = 0;
        if(status == false && temp == 3){
            status = true;
        }
      } {
        ar[i][0] = in.nextInt();
        ar[i][1] = in.nextInt();

        if(ar[i][0]==ar[i][1])
          temp++;
        else
          temp = 0;
        if(status == false && temp == 3){
            status = true;
        }
      } ar[i][0] = in.nextInt() ar[i][0] ar[i] ar i 0 in.nextInt() in.nextInt in ar[i][1] = in.nextInt() ar[i][1] ar[i] ar i 1 in.nextInt() in.nextInt in if(ar[i][0]==ar[i][1])
          temp++;
        else
          temp = 0; ar[i][0]==ar[i][1] ar[i][0] ar[i] ar i 0 ar[i][1] ar[i] ar i 1 temp++ temp temp = 0 temp 0 if(status == false && temp == 3){
            status = true;
        } status == false && temp == 3 status == false status false temp == 3 temp 3 {
            status = true;
        } status = true status true if(status == true)
        System.out.println("Yes");
      else
        System.out.println("No"); status == true status true System.out.println("Yes") System.out.println System.out System System.out "Yes" System.out.println("No") System.out.println System.out System System.out "No" String args[] args
import java.util.*;

class Main{
	public static void main(String args[]){
    	Scanner in = new Scanner(System.in);
      
      int n = in.nextInt();
      int ar[][] = new int[n][2];
      int temp = 0;
      boolean status = false;
      for(int i = 0 ; i < n ; i++){
        ar[i][0] = in.nextInt();
        ar[i][1] = in.nextInt();

        if(ar[i][0]==ar[i][1])
          temp++;
        else
          temp = 0;
        if(status == false && temp == 3){
            status = true;
        }
      }

      if(status == true)
        System.out.println("Yes");
      else
        System.out.println("No");
      
    }
}