import java.awt.*;
import java.io.*;
import java.util.*;
 
public class Main {
	Scanner sc = new Scanner(System.in);
	public static void main(String[] args){
		new Main();
	}
	public Main(){
		new TestB().doIt();
	}
	class TestB{
		void doIt() {
			int N = sc.nextInt();
			int cnt = 0;
			boolean renzoku3 = false;
			for(int i = 0;i < N;i++) {
				int D1 = sc.nextInt();
				int D2 = sc.nextInt();
				if(D1 == D2) {
					cnt++;
				}else {
					cnt = 0;
				}
				if(cnt >= 3) {
					renzoku3 = true;
				}
			}
			if(renzoku3)System.out.println("Yes");
			else System.out.println("No");
		}
	}
} import java.awt.*; awt.* java import java.io.*; io.* java import java.util.*; util.* java public class Main {
	Scanner sc = new Scanner(System.in);
	public static void main(String[] args){
		new Main();
	}
	public Main(){
		new TestB().doIt();
	}
	class TestB{
		void doIt() {
			int N = sc.nextInt();
			int cnt = 0;
			boolean renzoku3 = false;
			for(int i = 0;i < N;i++) {
				int D1 = sc.nextInt();
				int D2 = sc.nextInt();
				if(D1 == D2) {
					cnt++;
				}else {
					cnt = 0;
				}
				if(cnt >= 3) {
					renzoku3 = true;
				}
			}
			if(renzoku3)System.out.println("Yes");
			else System.out.println("No");
		}
	}
} Main Scanner sc = new Scanner(System.in); sc new Scanner(System.in) public static void main(String[] args){
		new Main();
	} main {
		new Main();
	} new Main() String[] args args public Main(){
		new TestB().doIt();
	} Main {
		new TestB().doIt();
	} new TestB().doIt() new TestB().doIt new TestB() class TestB{
		void doIt() {
			int N = sc.nextInt();
			int cnt = 0;
			boolean renzoku3 = false;
			for(int i = 0;i < N;i++) {
				int D1 = sc.nextInt();
				int D2 = sc.nextInt();
				if(D1 == D2) {
					cnt++;
				}else {
					cnt = 0;
				}
				if(cnt >= 3) {
					renzoku3 = true;
				}
			}
			if(renzoku3)System.out.println("Yes");
			else System.out.println("No");
		}
	} TestB void doIt() {
			int N = sc.nextInt();
			int cnt = 0;
			boolean renzoku3 = false;
			for(int i = 0;i < N;i++) {
				int D1 = sc.nextInt();
				int D2 = sc.nextInt();
				if(D1 == D2) {
					cnt++;
				}else {
					cnt = 0;
				}
				if(cnt >= 3) {
					renzoku3 = true;
				}
			}
			if(renzoku3)System.out.println("Yes");
			else System.out.println("No");
		} doIt {
			int N = sc.nextInt();
			int cnt = 0;
			boolean renzoku3 = false;
			for(int i = 0;i < N;i++) {
				int D1 = sc.nextInt();
				int D2 = sc.nextInt();
				if(D1 == D2) {
					cnt++;
				}else {
					cnt = 0;
				}
				if(cnt >= 3) {
					renzoku3 = true;
				}
			}
			if(renzoku3)System.out.println("Yes");
			else System.out.println("No");
		} int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int cnt = 0; cnt 0 boolean renzoku3 = false; renzoku3 false for(int i = 0;i < N;i++) {
				int D1 = sc.nextInt();
				int D2 = sc.nextInt();
				if(D1 == D2) {
					cnt++;
				}else {
					cnt = 0;
				}
				if(cnt >= 3) {
					renzoku3 = true;
				}
			} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
				int D1 = sc.nextInt();
				int D2 = sc.nextInt();
				if(D1 == D2) {
					cnt++;
				}else {
					cnt = 0;
				}
				if(cnt >= 3) {
					renzoku3 = true;
				}
			} {
				int D1 = sc.nextInt();
				int D2 = sc.nextInt();
				if(D1 == D2) {
					cnt++;
				}else {
					cnt = 0;
				}
				if(cnt >= 3) {
					renzoku3 = true;
				}
			} int D1 = sc.nextInt(); D1 sc.nextInt() sc.nextInt sc int D2 = sc.nextInt(); D2 sc.nextInt() sc.nextInt sc if(D1 == D2) {
					cnt++;
				}else {
					cnt = 0;
				} D1 == D2 D1 D2 {
					cnt++;
				} cnt++ cnt {
					cnt = 0;
				} cnt = 0 cnt 0 if(cnt >= 3) {
					renzoku3 = true;
				} cnt >= 3 cnt 3 {
					renzoku3 = true;
				} renzoku3 = true renzoku3 true if(renzoku3)System.out.println("Yes");
			else System.out.println("No"); renzoku3 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" public class Main {
	Scanner sc = new Scanner(System.in);
	public static void main(String[] args){
		new Main();
	}
	public Main(){
		new TestB().doIt();
	}
	class TestB{
		void doIt() {
			int N = sc.nextInt();
			int cnt = 0;
			boolean renzoku3 = false;
			for(int i = 0;i < N;i++) {
				int D1 = sc.nextInt();
				int D2 = sc.nextInt();
				if(D1 == D2) {
					cnt++;
				}else {
					cnt = 0;
				}
				if(cnt >= 3) {
					renzoku3 = true;
				}
			}
			if(renzoku3)System.out.println("Yes");
			else System.out.println("No");
		}
	}
} public class Main {
	Scanner sc = new Scanner(System.in);
	public static void main(String[] args){
		new Main();
	}
	public Main(){
		new TestB().doIt();
	}
	class TestB{
		void doIt() {
			int N = sc.nextInt();
			int cnt = 0;
			boolean renzoku3 = false;
			for(int i = 0;i < N;i++) {
				int D1 = sc.nextInt();
				int D2 = sc.nextInt();
				if(D1 == D2) {
					cnt++;
				}else {
					cnt = 0;
				}
				if(cnt >= 3) {
					renzoku3 = true;
				}
			}
			if(renzoku3)System.out.println("Yes");
			else System.out.println("No");
		}
	}
} Main
import java.awt.*;
import java.io.*;
import java.util.*;
 
public class Main {
	Scanner sc = new Scanner(System.in);
	public static void main(String[] args){
		new Main();
	}
	public Main(){
		new TestB().doIt();
	}
	class TestB{
		void doIt() {
			int N = sc.nextInt();
			int cnt = 0;
			boolean renzoku3 = false;
			for(int i = 0;i < N;i++) {
				int D1 = sc.nextInt();
				int D2 = sc.nextInt();
				if(D1 == D2) {
					cnt++;
				}else {
					cnt = 0;
				}
				if(cnt >= 3) {
					renzoku3 = true;
				}
			}
			if(renzoku3)System.out.println("Yes");
			else System.out.println("No");
		}
	}
}