import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		ArrayList<Integer> D = new ArrayList<Integer>();
		for(int i = 0; i < N * 2; i ++) {
			D.add(stdIn.nextInt());
		}
		
		int keepCnt = 0;
		boolean ans = false;
		for(int i = 0; i < N; i ++) {
			if(D.get(2 * i) == D.get(2 * i + 1)) {
				keepCnt ++;
			}else {
				keepCnt = 0;
			}
			if(keepCnt == 3) {
				ans = true;
				break;
			}
		}
		
		if(ans){
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
} import java.util.ArrayList; ArrayList java.util import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String args[]) {
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		ArrayList<Integer> D = new ArrayList<Integer>();
		for(int i = 0; i < N * 2; i ++) {
			D.add(stdIn.nextInt());
		}
		
		int keepCnt = 0;
		boolean ans = false;
		for(int i = 0; i < N; i ++) {
			if(D.get(2 * i) == D.get(2 * i + 1)) {
				keepCnt ++;
			}else {
				keepCnt = 0;
			}
			if(keepCnt == 3) {
				ans = true;
				break;
			}
		}
		
		if(ans){
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
} Main public static void main(String args[]) {
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		ArrayList<Integer> D = new ArrayList<Integer>();
		for(int i = 0; i < N * 2; i ++) {
			D.add(stdIn.nextInt());
		}
		
		int keepCnt = 0;
		boolean ans = false;
		for(int i = 0; i < N; i ++) {
			if(D.get(2 * i) == D.get(2 * i + 1)) {
				keepCnt ++;
			}else {
				keepCnt = 0;
			}
			if(keepCnt == 3) {
				ans = true;
				break;
			}
		}
		
		if(ans){
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	} main {
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		ArrayList<Integer> D = new ArrayList<Integer>();
		for(int i = 0; i < N * 2; i ++) {
			D.add(stdIn.nextInt());
		}
		
		int keepCnt = 0;
		boolean ans = false;
		for(int i = 0; i < N; i ++) {
			if(D.get(2 * i) == D.get(2 * i + 1)) {
				keepCnt ++;
			}else {
				keepCnt = 0;
			}
			if(keepCnt == 3) {
				ans = true;
				break;
			}
		}
		
		if(ans){
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	} Scanner stdIn = new Scanner(System.in); stdIn new Scanner(System.in) int N = stdIn.nextInt(); N stdIn.nextInt() stdIn.nextInt stdIn ArrayList<Integer> D = new ArrayList<Integer>(); D new ArrayList<Integer>() for(int i = 0; i < N * 2; i ++) {
			D.add(stdIn.nextInt());
		} int i = 0; int i = 0; i 0 i < N * 2 i N * 2 N 2 i ++ i ++ i {
			D.add(stdIn.nextInt());
		} {
			D.add(stdIn.nextInt());
		} D.add(stdIn.nextInt()) D.add D stdIn.nextInt() stdIn.nextInt stdIn int keepCnt = 0; keepCnt 0 boolean ans = false; ans false for(int i = 0; i < N; i ++) {
			if(D.get(2 * i) == D.get(2 * i + 1)) {
				keepCnt ++;
			}else {
				keepCnt = 0;
			}
			if(keepCnt == 3) {
				ans = true;
				break;
			}
		} int i = 0; int i = 0; i 0 i < N i N i ++ i ++ i {
			if(D.get(2 * i) == D.get(2 * i + 1)) {
				keepCnt ++;
			}else {
				keepCnt = 0;
			}
			if(keepCnt == 3) {
				ans = true;
				break;
			}
		} {
			if(D.get(2 * i) == D.get(2 * i + 1)) {
				keepCnt ++;
			}else {
				keepCnt = 0;
			}
			if(keepCnt == 3) {
				ans = true;
				break;
			}
		} if(D.get(2 * i) == D.get(2 * i + 1)) {
				keepCnt ++;
			}else {
				keepCnt = 0;
			} D.get(2 * i) == D.get(2 * i + 1) D.get(2 * i) D.get D 2 * i 2 i D.get(2 * i + 1) D.get D 2 * i + 1 2 * i 2 i 1 {
				keepCnt ++;
			} keepCnt ++ keepCnt {
				keepCnt = 0;
			} keepCnt = 0 keepCnt 0 if(keepCnt == 3) {
				ans = true;
				break;
			} keepCnt == 3 keepCnt 3 {
				ans = true;
				break;
			} ans = true ans true break; if(ans){
			System.out.println("Yes");
		}else {
			System.out.println("No");
		} ans {
			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 stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		ArrayList<Integer> D = new ArrayList<Integer>();
		for(int i = 0; i < N * 2; i ++) {
			D.add(stdIn.nextInt());
		}
		
		int keepCnt = 0;
		boolean ans = false;
		for(int i = 0; i < N; i ++) {
			if(D.get(2 * i) == D.get(2 * i + 1)) {
				keepCnt ++;
			}else {
				keepCnt = 0;
			}
			if(keepCnt == 3) {
				ans = true;
				break;
			}
		}
		
		if(ans){
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
} public class Main {
	public static void main(String args[]) {
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		ArrayList<Integer> D = new ArrayList<Integer>();
		for(int i = 0; i < N * 2; i ++) {
			D.add(stdIn.nextInt());
		}
		
		int keepCnt = 0;
		boolean ans = false;
		for(int i = 0; i < N; i ++) {
			if(D.get(2 * i) == D.get(2 * i + 1)) {
				keepCnt ++;
			}else {
				keepCnt = 0;
			}
			if(keepCnt == 3) {
				ans = true;
				break;
			}
		}
		
		if(ans){
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
} Main
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		ArrayList<Integer> D = new ArrayList<Integer>();
		for(int i = 0; i < N * 2; i ++) {
			D.add(stdIn.nextInt());
		}
		
		int keepCnt = 0;
		boolean ans = false;
		for(int i = 0; i < N; i ++) {
			if(D.get(2 * i) == D.get(2 * i + 1)) {
				keepCnt ++;
			}else {
				keepCnt = 0;
			}
			if(keepCnt == 3) {
				ans = true;
				break;
			}
		}
		
		if(ans){
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}