import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			boolean bl = false;
			int cnt = 0;
			for (int i = 0; i < n; i++) {
				int a = sc.nextInt();
				int b = sc.nextInt();
				if (a == b) {
					cnt++;
				} else {
					cnt = 0;
				}
				if (cnt >= 3) {
					bl = true;
				}
			}
			System.out.println(bl ? "Yes" : "No");
		}
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			boolean bl = false;
			int cnt = 0;
			for (int i = 0; i < n; i++) {
				int a = sc.nextInt();
				int b = sc.nextInt();
				if (a == b) {
					cnt++;
				} else {
					cnt = 0;
				}
				if (cnt >= 3) {
					bl = true;
				}
			}
			System.out.println(bl ? "Yes" : "No");
		}
	}
} Main public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			boolean bl = false;
			int cnt = 0;
			for (int i = 0; i < n; i++) {
				int a = sc.nextInt();
				int b = sc.nextInt();
				if (a == b) {
					cnt++;
				} else {
					cnt = 0;
				}
				if (cnt >= 3) {
					bl = true;
				}
			}
			System.out.println(bl ? "Yes" : "No");
		}
	} main {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			boolean bl = false;
			int cnt = 0;
			for (int i = 0; i < n; i++) {
				int a = sc.nextInt();
				int b = sc.nextInt();
				if (a == b) {
					cnt++;
				} else {
					cnt = 0;
				}
				if (cnt >= 3) {
					bl = true;
				}
			}
			System.out.println(bl ? "Yes" : "No");
		}
	} try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			boolean bl = false;
			int cnt = 0;
			for (int i = 0; i < n; i++) {
				int a = sc.nextInt();
				int b = sc.nextInt();
				if (a == b) {
					cnt++;
				} else {
					cnt = 0;
				}
				if (cnt >= 3) {
					bl = true;
				}
			}
			System.out.println(bl ? "Yes" : "No");
		} {
			int n = sc.nextInt();
			boolean bl = false;
			int cnt = 0;
			for (int i = 0; i < n; i++) {
				int a = sc.nextInt();
				int b = sc.nextInt();
				if (a == b) {
					cnt++;
				} else {
					cnt = 0;
				}
				if (cnt >= 3) {
					bl = true;
				}
			}
			System.out.println(bl ? "Yes" : "No");
		} Scanner sc = new Scanner(System.in) Scanner sc = new Scanner(System.in) new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc boolean bl = false; bl false int cnt = 0; cnt 0 for (int i = 0; i < n; i++) {
				int a = sc.nextInt();
				int b = sc.nextInt();
				if (a == b) {
					cnt++;
				} else {
					cnt = 0;
				}
				if (cnt >= 3) {
					bl = true;
				}
			} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
				int a = sc.nextInt();
				int b = sc.nextInt();
				if (a == b) {
					cnt++;
				} else {
					cnt = 0;
				}
				if (cnt >= 3) {
					bl = true;
				}
			} {
				int a = sc.nextInt();
				int b = sc.nextInt();
				if (a == b) {
					cnt++;
				} else {
					cnt = 0;
				}
				if (cnt >= 3) {
					bl = true;
				}
			} int a = sc.nextInt(); a sc.nextInt() sc.nextInt sc int b = sc.nextInt(); b sc.nextInt() sc.nextInt sc if (a == b) {
					cnt++;
				} else {
					cnt = 0;
				} a == b a b {
					cnt++;
				} cnt++ cnt {
					cnt = 0;
				} cnt = 0 cnt 0 if (cnt >= 3) {
					bl = true;
				} cnt >= 3 cnt 3 {
					bl = true;
				} bl = true bl true System.out.println(bl ? "Yes" : "No") System.out.println System.out System System.out bl ? "Yes" : "No" bl "Yes" "No" String[] args args public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			boolean bl = false;
			int cnt = 0;
			for (int i = 0; i < n; i++) {
				int a = sc.nextInt();
				int b = sc.nextInt();
				if (a == b) {
					cnt++;
				} else {
					cnt = 0;
				}
				if (cnt >= 3) {
					bl = true;
				}
			}
			System.out.println(bl ? "Yes" : "No");
		}
	}
} public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			boolean bl = false;
			int cnt = 0;
			for (int i = 0; i < n; i++) {
				int a = sc.nextInt();
				int b = sc.nextInt();
				if (a == b) {
					cnt++;
				} else {
					cnt = 0;
				}
				if (cnt >= 3) {
					bl = true;
				}
			}
			System.out.println(bl ? "Yes" : "No");
		}
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			boolean bl = false;
			int cnt = 0;
			for (int i = 0; i < n; i++) {
				int a = sc.nextInt();
				int b = sc.nextInt();
				if (a == b) {
					cnt++;
				} else {
					cnt = 0;
				}
				if (cnt >= 3) {
					bl = true;
				}
			}
			System.out.println(bl ? "Yes" : "No");
		}
	}
}