import java.util.*;
class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();int cnt=0;boolean f=false;
		while(n--!=0) {
			int d1=sc.nextInt(),d2=sc.nextInt();
			if(d1==d2)cnt++;
			else if(d1!=d2)cnt=0;
			if(cnt>=3)f=true;
		}
		if(f)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 n=sc.nextInt();int cnt=0;boolean f=false;
		while(n--!=0) {
			int d1=sc.nextInt(),d2=sc.nextInt();
			if(d1==d2)cnt++;
			else if(d1!=d2)cnt=0;
			if(cnt>=3)f=true;
		}
		if(f)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 cnt=0;boolean f=false;
		while(n--!=0) {
			int d1=sc.nextInt(),d2=sc.nextInt();
			if(d1==d2)cnt++;
			else if(d1!=d2)cnt=0;
			if(cnt>=3)f=true;
		}
		if(f)System.out.println("Yes");
		else System.out.println("No");
	} main {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();int cnt=0;boolean f=false;
		while(n--!=0) {
			int d1=sc.nextInt(),d2=sc.nextInt();
			if(d1==d2)cnt++;
			else if(d1!=d2)cnt=0;
			if(cnt>=3)f=true;
		}
		if(f)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 cnt=0; cnt 0 boolean f=false; f false while(n--!=0) {
			int d1=sc.nextInt(),d2=sc.nextInt();
			if(d1==d2)cnt++;
			else if(d1!=d2)cnt=0;
			if(cnt>=3)f=true;
		} n--!=0 n-- n 0 {
			int d1=sc.nextInt(),d2=sc.nextInt();
			if(d1==d2)cnt++;
			else if(d1!=d2)cnt=0;
			if(cnt>=3)f=true;
		} int d1=sc.nextInt() d1 sc.nextInt() sc.nextInt sc d2=sc.nextInt(); d2 sc.nextInt() sc.nextInt sc if(d1==d2)cnt++;
			else if(d1!=d2)cnt=0; d1==d2 d1 d2 cnt++ cnt if(d1!=d2)cnt=0; d1!=d2 d1 d2 cnt=0 cnt 0 if(cnt>=3)f=true; cnt>=3 cnt 3 f=true f true if(f)System.out.println("Yes");
		else System.out.println("No"); f 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 n=sc.nextInt();int cnt=0;boolean f=false;
		while(n--!=0) {
			int d1=sc.nextInt(),d2=sc.nextInt();
			if(d1==d2)cnt++;
			else if(d1!=d2)cnt=0;
			if(cnt>=3)f=true;
		}
		if(f)System.out.println("Yes");
		else System.out.println("No");
	}

}
