/* package codechef; // don't place package name! */
 
import java.util.*;
import java.lang.*;
import java.io.*;
 
/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
  /* Name of the class has to be "Main" only if the class is public. */
	public static void main (String[] args) throws java.lang.Exception
	{
      /* Name of the class has to be "Main" only if the class is public. */
	    Scanner syed=new Scanner(System.in);
	    int looplim=syed.nextInt();
	    boolean hua=false; 
	    int count=0;
	    for(int iter=0;iter<looplim;iter++)
	    {
	        int a=syed.nextInt();
	        int b=syed.nextInt();
	        if(a==b){count++;
	        if(count>=3) hua=true;}
	        else {count=0;}
	        
	    
	    }
	    if (hua)
	    System.out.println("Yes");
	    else
	    System.out.println("No");
	        
	}
} import java.util.*; util.* java import java.lang.*; lang.* java import java.io.*; io.* java public class Main
{
  /* Name of the class has to be "Main" only if the class is public. */
	public static void main (String[] args) throws java.lang.Exception
	{
      /* Name of the class has to be "Main" only if the class is public. */
	    Scanner syed=new Scanner(System.in);
	    int looplim=syed.nextInt();
	    boolean hua=false; 
	    int count=0;
	    for(int iter=0;iter<looplim;iter++)
	    {
	        int a=syed.nextInt();
	        int b=syed.nextInt();
	        if(a==b){count++;
	        if(count>=3) hua=true;}
	        else {count=0;}
	        
	    
	    }
	    if (hua)
	    System.out.println("Yes");
	    else
	    System.out.println("No");
	        
	}
} Main /* Name of the class has to be "Main" only if the class is public. */
	public static void main (String[] args) throws java.lang.Exception
	{
      /* Name of the class has to be "Main" only if the class is public. */
	    Scanner syed=new Scanner(System.in);
	    int looplim=syed.nextInt();
	    boolean hua=false; 
	    int count=0;
	    for(int iter=0;iter<looplim;iter++)
	    {
	        int a=syed.nextInt();
	        int b=syed.nextInt();
	        if(a==b){count++;
	        if(count>=3) hua=true;}
	        else {count=0;}
	        
	    
	    }
	    if (hua)
	    System.out.println("Yes");
	    else
	    System.out.println("No");
	        
	} main {
      /* Name of the class has to be "Main" only if the class is public. */
	    Scanner syed=new Scanner(System.in);
	    int looplim=syed.nextInt();
	    boolean hua=false; 
	    int count=0;
	    for(int iter=0;iter<looplim;iter++)
	    {
	        int a=syed.nextInt();
	        int b=syed.nextInt();
	        if(a==b){count++;
	        if(count>=3) hua=true;}
	        else {count=0;}
	        
	    
	    }
	    if (hua)
	    System.out.println("Yes");
	    else
	    System.out.println("No");
	        
	} Scanner syed=new Scanner(System.in); syed new Scanner(System.in) int looplim=syed.nextInt(); looplim syed.nextInt() syed.nextInt syed boolean hua=false; hua false int count=0; count 0 for(int iter=0;iter<looplim;iter++)
	    {
	        int a=syed.nextInt();
	        int b=syed.nextInt();
	        if(a==b){count++;
	        if(count>=3) hua=true;}
	        else {count=0;}
	        
	    
	    } int iter=0; int iter=0; iter 0 iter<looplim iter looplim iter++ iter++ iter {
	        int a=syed.nextInt();
	        int b=syed.nextInt();
	        if(a==b){count++;
	        if(count>=3) hua=true;}
	        else {count=0;}
	        
	    
	    } {
	        int a=syed.nextInt();
	        int b=syed.nextInt();
	        if(a==b){count++;
	        if(count>=3) hua=true;}
	        else {count=0;}
	        
	    
	    } int a=syed.nextInt(); a syed.nextInt() syed.nextInt syed int b=syed.nextInt(); b syed.nextInt() syed.nextInt syed if(a==b){count++;
	        if(count>=3) hua=true;}
	        else {count=0;} a==b a b {count++;
	        if(count>=3) hua=true;} count++ count if(count>=3) hua=true; count>=3 count 3 hua=true hua true {count=0;} count=0 count 0 if (hua)
	    System.out.println("Yes");
	    else
	    System.out.println("No"); hua 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 public class Main
{
  /* Name of the class has to be "Main" only if the class is public. */
	public static void main (String[] args) throws java.lang.Exception
	{
      /* Name of the class has to be "Main" only if the class is public. */
	    Scanner syed=new Scanner(System.in);
	    int looplim=syed.nextInt();
	    boolean hua=false; 
	    int count=0;
	    for(int iter=0;iter<looplim;iter++)
	    {
	        int a=syed.nextInt();
	        int b=syed.nextInt();
	        if(a==b){count++;
	        if(count>=3) hua=true;}
	        else {count=0;}
	        
	    
	    }
	    if (hua)
	    System.out.println("Yes");
	    else
	    System.out.println("No");
	        
	}
} public class Main
{
  /* Name of the class has to be "Main" only if the class is public. */
	public static void main (String[] args) throws java.lang.Exception
	{
      /* Name of the class has to be "Main" only if the class is public. */
	    Scanner syed=new Scanner(System.in);
	    int looplim=syed.nextInt();
	    boolean hua=false; 
	    int count=0;
	    for(int iter=0;iter<looplim;iter++)
	    {
	        int a=syed.nextInt();
	        int b=syed.nextInt();
	        if(a==b){count++;
	        if(count>=3) hua=true;}
	        else {count=0;}
	        
	    
	    }
	    if (hua)
	    System.out.println("Yes");
	    else
	    System.out.println("No");
	        
	}
} Main
/* package codechef; // don't place package name! */
 
import java.util.*;
import java.lang.*;
import java.io.*;
 
/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
  /* Name of the class has to be "Main" only if the class is public. */
	public static void main (String[] args) throws java.lang.Exception
	{
      /* Name of the class has to be "Main" only if the class is public. */
	    Scanner syed=new Scanner(System.in);
	    int looplim=syed.nextInt();
	    boolean hua=false; 
	    int count=0;
	    for(int iter=0;iter<looplim;iter++)
	    {
	        int a=syed.nextInt();
	        int b=syed.nextInt();
	        if(a==b){count++;
	        if(count>=3) hua=true;}
	        else {count=0;}
	        
	    
	    }
	    if (hua)
	    System.out.println("Yes");
	    else
	    System.out.println("No");
	        
	}
}