import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int s=sc.nextInt();
    int d1=0,d2=0,count=0;
    for(int i=0;i<s;i++){
      d1=sc.nextInt();
      d2=sc.nextInt();
      if(d1==d2){
        count++;
        if(count==3)break;
      }
      else{
        count=0;
      }
      
    }
    if(count>=3)System.out.println("Yes");
    else System.out.println("No");
  }
} import java.util.*; util.* java class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int s=sc.nextInt();
    int d1=0,d2=0,count=0;
    for(int i=0;i<s;i++){
      d1=sc.nextInt();
      d2=sc.nextInt();
      if(d1==d2){
        count++;
        if(count==3)break;
      }
      else{
        count=0;
      }
      
    }
    if(count>=3)System.out.println("Yes");
    else System.out.println("No");
  }
} Main public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int s=sc.nextInt();
    int d1=0,d2=0,count=0;
    for(int i=0;i<s;i++){
      d1=sc.nextInt();
      d2=sc.nextInt();
      if(d1==d2){
        count++;
        if(count==3)break;
      }
      else{
        count=0;
      }
      
    }
    if(count>=3)System.out.println("Yes");
    else System.out.println("No");
  } main {
    Scanner sc=new Scanner(System.in);
    int s=sc.nextInt();
    int d1=0,d2=0,count=0;
    for(int i=0;i<s;i++){
      d1=sc.nextInt();
      d2=sc.nextInt();
      if(d1==d2){
        count++;
        if(count==3)break;
      }
      else{
        count=0;
      }
      
    }
    if(count>=3)System.out.println("Yes");
    else System.out.println("No");
  } Scanner sc=new Scanner(System.in); sc new Scanner(System.in) int s=sc.nextInt(); s sc.nextInt() sc.nextInt sc int d1=0 d1 0 d2=0 d2 0 count=0; count 0 for(int i=0;i<s;i++){
      d1=sc.nextInt();
      d2=sc.nextInt();
      if(d1==d2){
        count++;
        if(count==3)break;
      }
      else{
        count=0;
      }
      
    } int i=0; int i=0; i 0 i<s i s i++ i++ i {
      d1=sc.nextInt();
      d2=sc.nextInt();
      if(d1==d2){
        count++;
        if(count==3)break;
      }
      else{
        count=0;
      }
      
    } {
      d1=sc.nextInt();
      d2=sc.nextInt();
      if(d1==d2){
        count++;
        if(count==3)break;
      }
      else{
        count=0;
      }
      
    } d1=sc.nextInt() d1 sc.nextInt() sc.nextInt sc d2=sc.nextInt() d2 sc.nextInt() sc.nextInt sc if(d1==d2){
        count++;
        if(count==3)break;
      }
      else{
        count=0;
      } d1==d2 d1 d2 {
        count++;
        if(count==3)break;
      } count++ count if(count==3)break; count==3 count 3 break; {
        count=0;
      } count=0 count 0 if(count>=3)System.out.println("Yes");
    else System.out.println("No"); count>=3 count 3 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 sc=new Scanner(System.in);
    int s=sc.nextInt();
    int d1=0,d2=0,count=0;
    for(int i=0;i<s;i++){
      d1=sc.nextInt();
      d2=sc.nextInt();
      if(d1==d2){
        count++;
        if(count==3)break;
      }
      else{
        count=0;
      }
      
    }
    if(count>=3)System.out.println("Yes");
    else System.out.println("No");
  }
}