import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
     Scanner sc=new Scanner(System.in);
     if(sc.hasNextInt()) 
      {
        int n=sc.nextInt();
        int arr[][]=new int[n][2];
     	for(int i=0;i<n;i++)
     	{
           arr[i][0]=sc.nextInt();
	   arr[i][1]=sc.nextInt();  
 	}
        deployB obj=new deployB();
          boolean ans=obj.solve(arr,n);
          if(ans==true)
          System.out.println("Yes");
          else
          System.out.println("No");  
      }
        
  }
    
}
class deployB
{
    public boolean solve(int a[][],int n)
    {
        int cnt=0;
        for(int i=0;i<n;i++)
        {
            if(a[i][0]==a[i][1])
            {
                cnt++;
            }
            else
                cnt=0;
            if(cnt==3)
                return true;
        }
        return false;
    }
    
} import java.util.*; util.* java import java.lang.*; lang.* java import java.io.*; io.* java public class Main {
    public static void main(String[] args) {
     Scanner sc=new Scanner(System.in);
     if(sc.hasNextInt()) 
      {
        int n=sc.nextInt();
        int arr[][]=new int[n][2];
     	for(int i=0;i<n;i++)
     	{
           arr[i][0]=sc.nextInt();
	   arr[i][1]=sc.nextInt();  
 	}
        deployB obj=new deployB();
          boolean ans=obj.solve(arr,n);
          if(ans==true)
          System.out.println("Yes");
          else
          System.out.println("No");  
      }
        
  }
    
} Main public static void main(String[] args) {
     Scanner sc=new Scanner(System.in);
     if(sc.hasNextInt()) 
      {
        int n=sc.nextInt();
        int arr[][]=new int[n][2];
     	for(int i=0;i<n;i++)
     	{
           arr[i][0]=sc.nextInt();
	   arr[i][1]=sc.nextInt();  
 	}
        deployB obj=new deployB();
          boolean ans=obj.solve(arr,n);
          if(ans==true)
          System.out.println("Yes");
          else
          System.out.println("No");  
      }
        
  } main {
     Scanner sc=new Scanner(System.in);
     if(sc.hasNextInt()) 
      {
        int n=sc.nextInt();
        int arr[][]=new int[n][2];
     	for(int i=0;i<n;i++)
     	{
           arr[i][0]=sc.nextInt();
	   arr[i][1]=sc.nextInt();  
 	}
        deployB obj=new deployB();
          boolean ans=obj.solve(arr,n);
          if(ans==true)
          System.out.println("Yes");
          else
          System.out.println("No");  
      }
        
  } Scanner sc=new Scanner(System.in); sc new Scanner(System.in) if(sc.hasNextInt()) 
      {
        int n=sc.nextInt();
        int arr[][]=new int[n][2];
     	for(int i=0;i<n;i++)
     	{
           arr[i][0]=sc.nextInt();
	   arr[i][1]=sc.nextInt();  
 	}
        deployB obj=new deployB();
          boolean ans=obj.solve(arr,n);
          if(ans==true)
          System.out.println("Yes");
          else
          System.out.println("No");  
      } sc.hasNextInt() sc.hasNextInt sc {
        int n=sc.nextInt();
        int arr[][]=new int[n][2];
     	for(int i=0;i<n;i++)
     	{
           arr[i][0]=sc.nextInt();
	   arr[i][1]=sc.nextInt();  
 	}
        deployB obj=new deployB();
          boolean ans=obj.solve(arr,n);
          if(ans==true)
          System.out.println("Yes");
          else
          System.out.println("No");  
      } int n=sc.nextInt(); n sc.nextInt() sc.nextInt sc int arr[][]=new int[n][2]; arr new int[n][2] n 2 for(int i=0;i<n;i++)
     	{
           arr[i][0]=sc.nextInt();
	   arr[i][1]=sc.nextInt();  
 	} int i=0; int i=0; i 0 i<n i n i++ i++ i {
           arr[i][0]=sc.nextInt();
	   arr[i][1]=sc.nextInt();  
 	} {
           arr[i][0]=sc.nextInt();
	   arr[i][1]=sc.nextInt();  
 	} arr[i][0]=sc.nextInt() arr[i][0] arr[i] arr i 0 sc.nextInt() sc.nextInt sc arr[i][1]=sc.nextInt() arr[i][1] arr[i] arr i 1 sc.nextInt() sc.nextInt sc deployB obj=new deployB(); obj new deployB() boolean ans=obj.solve(arr,n); ans obj.solve(arr,n) obj.solve obj arr n if(ans==true)
          System.out.println("Yes");
          else
          System.out.println("No"); ans==true ans 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 class deployB
{
    public boolean solve(int a[][],int n)
    {
        int cnt=0;
        for(int i=0;i<n;i++)
        {
            if(a[i][0]==a[i][1])
            {
                cnt++;
            }
            else
                cnt=0;
            if(cnt==3)
                return true;
        }
        return false;
    }
    
} deployB public boolean solve(int a[][],int n)
    {
        int cnt=0;
        for(int i=0;i<n;i++)
        {
            if(a[i][0]==a[i][1])
            {
                cnt++;
            }
            else
                cnt=0;
            if(cnt==3)
                return true;
        }
        return false;
    } solve {
        int cnt=0;
        for(int i=0;i<n;i++)
        {
            if(a[i][0]==a[i][1])
            {
                cnt++;
            }
            else
                cnt=0;
            if(cnt==3)
                return true;
        }
        return false;
    } int cnt=0; cnt 0 for(int i=0;i<n;i++)
        {
            if(a[i][0]==a[i][1])
            {
                cnt++;
            }
            else
                cnt=0;
            if(cnt==3)
                return true;
        } int i=0; int i=0; i 0 i<n i n i++ i++ i {
            if(a[i][0]==a[i][1])
            {
                cnt++;
            }
            else
                cnt=0;
            if(cnt==3)
                return true;
        } {
            if(a[i][0]==a[i][1])
            {
                cnt++;
            }
            else
                cnt=0;
            if(cnt==3)
                return true;
        } if(a[i][0]==a[i][1])
            {
                cnt++;
            }
            else
                cnt=0; a[i][0]==a[i][1] a[i][0] a[i] a i 0 a[i][1] a[i] a i 1 {
                cnt++;
            } cnt++ cnt cnt=0 cnt 0 if(cnt==3)
                return true; cnt==3 cnt 3 return true; true return false; false int a[][] a int n n public class Main {
    public static void main(String[] args) {
     Scanner sc=new Scanner(System.in);
     if(sc.hasNextInt()) 
      {
        int n=sc.nextInt();
        int arr[][]=new int[n][2];
     	for(int i=0;i<n;i++)
     	{
           arr[i][0]=sc.nextInt();
	   arr[i][1]=sc.nextInt();  
 	}
        deployB obj=new deployB();
          boolean ans=obj.solve(arr,n);
          if(ans==true)
          System.out.println("Yes");
          else
          System.out.println("No");  
      }
        
  }
    
} public class Main {
    public static void main(String[] args) {
     Scanner sc=new Scanner(System.in);
     if(sc.hasNextInt()) 
      {
        int n=sc.nextInt();
        int arr[][]=new int[n][2];
     	for(int i=0;i<n;i++)
     	{
           arr[i][0]=sc.nextInt();
	   arr[i][1]=sc.nextInt();  
 	}
        deployB obj=new deployB();
          boolean ans=obj.solve(arr,n);
          if(ans==true)
          System.out.println("Yes");
          else
          System.out.println("No");  
      }
        
  }
    
} Main
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
     Scanner sc=new Scanner(System.in);
     if(sc.hasNextInt()) 
      {
        int n=sc.nextInt();
        int arr[][]=new int[n][2];
     	for(int i=0;i<n;i++)
     	{
           arr[i][0]=sc.nextInt();
	   arr[i][1]=sc.nextInt();  
 	}
        deployB obj=new deployB();
          boolean ans=obj.solve(arr,n);
          if(ans==true)
          System.out.println("Yes");
          else
          System.out.println("No");  
      }
        
  }
    
}
class deployB
{
    public boolean solve(int a[][],int n)
    {
        int cnt=0;
        for(int i=0;i<n;i++)
        {
            if(a[i][0]==a[i][1])
            {
                cnt++;
            }
            else
                cnt=0;
            if(cnt==3)
                return true;
        }
        return false;
    }
    
}
