
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int max = 0;
			int cnt = 0;

			for (int i = 0; i < n; i++) {
				if (sc.nextInt() == sc.nextInt()) {
					cnt++;
				} else {
					cnt = 0;
				}
				if (max < cnt) {
					max = cnt;
				}
			}
			if (max >= 3) {
				System.out.println("Yes");
			} else {
				System.out.println("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();
			int max = 0;
			int cnt = 0;

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

			for (int i = 0; i < n; i++) {
				if (sc.nextInt() == sc.nextInt()) {
					cnt++;
				} else {
					cnt = 0;
				}
				if (max < cnt) {
					max = cnt;
				}
			}
			if (max >= 3) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		}
	} main {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int max = 0;
			int cnt = 0;

			for (int i = 0; i < n; i++) {
				if (sc.nextInt() == sc.nextInt()) {
					cnt++;
				} else {
					cnt = 0;
				}
				if (max < cnt) {
					max = cnt;
				}
			}
			if (max >= 3) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		}
	} try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int max = 0;
			int cnt = 0;

			for (int i = 0; i < n; i++) {
				if (sc.nextInt() == sc.nextInt()) {
					cnt++;
				} else {
					cnt = 0;
				}
				if (max < cnt) {
					max = cnt;
				}
			}
			if (max >= 3) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		} {
			int n = sc.nextInt();
			int max = 0;
			int cnt = 0;

			for (int i = 0; i < n; i++) {
				if (sc.nextInt() == sc.nextInt()) {
					cnt++;
				} else {
					cnt = 0;
				}
				if (max < cnt) {
					max = cnt;
				}
			}
			if (max >= 3) {
				System.out.println("Yes");
			} else {
				System.out.println("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 int max = 0; max 0 int cnt = 0; cnt 0 for (int i = 0; i < n; i++) {
				if (sc.nextInt() == sc.nextInt()) {
					cnt++;
				} else {
					cnt = 0;
				}
				if (max < cnt) {
					max = cnt;
				}
			} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
				if (sc.nextInt() == sc.nextInt()) {
					cnt++;
				} else {
					cnt = 0;
				}
				if (max < cnt) {
					max = cnt;
				}
			} {
				if (sc.nextInt() == sc.nextInt()) {
					cnt++;
				} else {
					cnt = 0;
				}
				if (max < cnt) {
					max = cnt;
				}
			} if (sc.nextInt() == sc.nextInt()) {
					cnt++;
				} else {
					cnt = 0;
				} sc.nextInt() == sc.nextInt() sc.nextInt() sc.nextInt sc sc.nextInt() sc.nextInt sc {
					cnt++;
				} cnt++ cnt {
					cnt = 0;
				} cnt = 0 cnt 0 if (max < cnt) {
					max = cnt;
				} max < cnt max cnt {
					max = cnt;
				} max = cnt max cnt 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) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int max = 0;
			int cnt = 0;

			for (int i = 0; i < n; i++) {
				if (sc.nextInt() == sc.nextInt()) {
					cnt++;
				} else {
					cnt = 0;
				}
				if (max < cnt) {
					max = cnt;
				}
			}
			if (max >= 3) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		}
	}
} public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int max = 0;
			int cnt = 0;

			for (int i = 0; i < n; i++) {
				if (sc.nextInt() == sc.nextInt()) {
					cnt++;
				} else {
					cnt = 0;
				}
				if (max < cnt) {
					max = cnt;
				}
			}
			if (max >= 3) {
				System.out.println("Yes");
			} else {
				System.out.println("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();
			int max = 0;
			int cnt = 0;

			for (int i = 0; i < n; i++) {
				if (sc.nextInt() == sc.nextInt()) {
					cnt++;
				} else {
					cnt = 0;
				}
				if (max < cnt) {
					max = cnt;
				}
			}
			if (max >= 3) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		}
	}
}
