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