import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int arr[][]=new int[n][2];
        for(int i=0;i<n;i++)
        {
        	for(int j=0;j<=1;j++)
        		arr[i][j]=sc.nextInt();
        }
        int ct=0,bl=0;
        for(int i=0;i<n;i++)
        {
        	if(ct==3)
        	{
        		bl=1;
        		break;
        	}
        	else if(arr[i][0]==arr[i][1])
        		ct=ct+1;
        	else
        		ct=0;
        }
        if(bl==1 || ct==3)
        	System.out.println("Yes");
        else
        	System.out.println("No");
	}

} import java.util.*; util.* java public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int arr[][]=new int[n][2];
        for(int i=0;i<n;i++)
        {
        	for(int j=0;j<=1;j++)
        		arr[i][j]=sc.nextInt();
        }
        int ct=0,bl=0;
        for(int i=0;i<n;i++)
        {
        	if(ct==3)
        	{
        		bl=1;
        		break;
        	}
        	else if(arr[i][0]==arr[i][1])
        		ct=ct+1;
        	else
        		ct=0;
        }
        if(bl==1 || ct==3)
        	System.out.println("Yes");
        else
        	System.out.println("No");
	}

} Main public static void main(String[] args) {
		// TODO Auto-generated method stub
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int arr[][]=new int[n][2];
        for(int i=0;i<n;i++)
        {
        	for(int j=0;j<=1;j++)
        		arr[i][j]=sc.nextInt();
        }
        int ct=0,bl=0;
        for(int i=0;i<n;i++)
        {
        	if(ct==3)
        	{
        		bl=1;
        		break;
        	}
        	else if(arr[i][0]==arr[i][1])
        		ct=ct+1;
        	else
        		ct=0;
        }
        if(bl==1 || ct==3)
        	System.out.println("Yes");
        else
        	System.out.println("No");
	} main {
		// TODO Auto-generated method stub
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int arr[][]=new int[n][2];
        for(int i=0;i<n;i++)
        {
        	for(int j=0;j<=1;j++)
        		arr[i][j]=sc.nextInt();
        }
        int ct=0,bl=0;
        for(int i=0;i<n;i++)
        {
        	if(ct==3)
        	{
        		bl=1;
        		break;
        	}
        	else if(arr[i][0]==arr[i][1])
        		ct=ct+1;
        	else
        		ct=0;
        }
        if(bl==1 || ct==3)
        	System.out.println("Yes");
        else
        	System.out.println("No");
	} Scanner sc=new Scanner(System.in); sc new Scanner(System.in) 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++)
        {
        	for(int j=0;j<=1;j++)
        		arr[i][j]=sc.nextInt();
        } int i=0; int i=0; i 0 i<n i n i++ i++ i {
        	for(int j=0;j<=1;j++)
        		arr[i][j]=sc.nextInt();
        } {
        	for(int j=0;j<=1;j++)
        		arr[i][j]=sc.nextInt();
        } for(int j=0;j<=1;j++)
        		arr[i][j]=sc.nextInt(); int j=0; int j=0; j 0 j<=1 j 1 j++ j++ j arr[i][j]=sc.nextInt(); arr[i][j]=sc.nextInt() arr[i][j] arr[i] arr i j sc.nextInt() sc.nextInt sc int ct=0 ct 0 bl=0; bl 0 for(int i=0;i<n;i++)
        {
        	if(ct==3)
        	{
        		bl=1;
        		break;
        	}
        	else if(arr[i][0]==arr[i][1])
        		ct=ct+1;
        	else
        		ct=0;
        } int i=0; int i=0; i 0 i<n i n i++ i++ i {
        	if(ct==3)
        	{
        		bl=1;
        		break;
        	}
        	else if(arr[i][0]==arr[i][1])
        		ct=ct+1;
        	else
        		ct=0;
        } {
        	if(ct==3)
        	{
        		bl=1;
        		break;
        	}
        	else if(arr[i][0]==arr[i][1])
        		ct=ct+1;
        	else
        		ct=0;
        } if(ct==3)
        	{
        		bl=1;
        		break;
        	}
        	else if(arr[i][0]==arr[i][1])
        		ct=ct+1;
        	else
        		ct=0; ct==3 ct 3 {
        		bl=1;
        		break;
        	} bl=1 bl 1 break; if(arr[i][0]==arr[i][1])
        		ct=ct+1;
        	else
        		ct=0; arr[i][0]==arr[i][1] arr[i][0] arr[i] arr i 0 arr[i][1] arr[i] arr i 1 ct=ct+1 ct ct+1 ct 1 ct=0 ct 0 if(bl==1 || ct==3)
        	System.out.println("Yes");
        else
        	System.out.println("No"); bl==1 || ct==3 bl==1 bl 1 ct==3 ct 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 public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int arr[][]=new int[n][2];
        for(int i=0;i<n;i++)
        {
        	for(int j=0;j<=1;j++)
        		arr[i][j]=sc.nextInt();
        }
        int ct=0,bl=0;
        for(int i=0;i<n;i++)
        {
        	if(ct==3)
        	{
        		bl=1;
        		break;
        	}
        	else if(arr[i][0]==arr[i][1])
        		ct=ct+1;
        	else
        		ct=0;
        }
        if(bl==1 || ct==3)
        	System.out.println("Yes");
        else
        	System.out.println("No");
	}

} public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int arr[][]=new int[n][2];
        for(int i=0;i<n;i++)
        {
        	for(int j=0;j<=1;j++)
        		arr[i][j]=sc.nextInt();
        }
        int ct=0,bl=0;
        for(int i=0;i<n;i++)
        {
        	if(ct==3)
        	{
        		bl=1;
        		break;
        	}
        	else if(arr[i][0]==arr[i][1])
        		ct=ct+1;
        	else
        		ct=0;
        }
        if(bl==1 || ct==3)
        	System.out.println("Yes");
        else
        	System.out.println("No");
	}

} Main
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int arr[][]=new int[n][2];
        for(int i=0;i<n;i++)
        {
        	for(int j=0;j<=1;j++)
        		arr[i][j]=sc.nextInt();
        }
        int ct=0,bl=0;
        for(int i=0;i<n;i++)
        {
        	if(ct==3)
        	{
        		bl=1;
        		break;
        	}
        	else if(arr[i][0]==arr[i][1])
        		ct=ct+1;
        	else
        		ct=0;
        }
        if(bl==1 || ct==3)
        	System.out.println("Yes");
        else
        	System.out.println("No");
	}

}
