import java.util.Scanner;

public class Main {

		public static void main(String[] args) {
			// TODO Auto-generated method stub
			try (Scanner sc = new Scanner(System.in)) {
				int N = sc.nextInt();
				int a = 0;
				int b = 0;
				int count = 0;
				String ans = "No";
				for (int i = 0; i < N; i++) {
					a = sc.nextInt();
					b = sc.nextInt();

					if (count == 0 && a == b) {
						count = 1;
					} else if (count > 0 && a == b) {
						count++;
					} else {
						count = 0;
					}
					if (count > 2) {
						ans = "Yes";
					} 
				}

				System.out.println(ans);
			} catch (Exception e) {
				// TODO: handle exception
			}
		}
} import java.util.Scanner; Scanner java.util public class Main {

		public static void main(String[] args) {
			// TODO Auto-generated method stub
			try (Scanner sc = new Scanner(System.in)) {
				int N = sc.nextInt();
				int a = 0;
				int b = 0;
				int count = 0;
				String ans = "No";
				for (int i = 0; i < N; i++) {
					a = sc.nextInt();
					b = sc.nextInt();

					if (count == 0 && a == b) {
						count = 1;
					} else if (count > 0 && a == b) {
						count++;
					} else {
						count = 0;
					}
					if (count > 2) {
						ans = "Yes";
					} 
				}

				System.out.println(ans);
			} catch (Exception e) {
				// TODO: handle exception
			}
		}
} Main public static void main(String[] args) {
			// TODO Auto-generated method stub
			try (Scanner sc = new Scanner(System.in)) {
				int N = sc.nextInt();
				int a = 0;
				int b = 0;
				int count = 0;
				String ans = "No";
				for (int i = 0; i < N; i++) {
					a = sc.nextInt();
					b = sc.nextInt();

					if (count == 0 && a == b) {
						count = 1;
					} else if (count > 0 && a == b) {
						count++;
					} else {
						count = 0;
					}
					if (count > 2) {
						ans = "Yes";
					} 
				}

				System.out.println(ans);
			} catch (Exception e) {
				// TODO: handle exception
			}
		} main {
			// TODO Auto-generated method stub
			try (Scanner sc = new Scanner(System.in)) {
				int N = sc.nextInt();
				int a = 0;
				int b = 0;
				int count = 0;
				String ans = "No";
				for (int i = 0; i < N; i++) {
					a = sc.nextInt();
					b = sc.nextInt();

					if (count == 0 && a == b) {
						count = 1;
					} else if (count > 0 && a == b) {
						count++;
					} else {
						count = 0;
					}
					if (count > 2) {
						ans = "Yes";
					} 
				}

				System.out.println(ans);
			} catch (Exception e) {
				// TODO: handle exception
			}
		} try (Scanner sc = new Scanner(System.in)) {
				int N = sc.nextInt();
				int a = 0;
				int b = 0;
				int count = 0;
				String ans = "No";
				for (int i = 0; i < N; i++) {
					a = sc.nextInt();
					b = sc.nextInt();

					if (count == 0 && a == b) {
						count = 1;
					} else if (count > 0 && a == b) {
						count++;
					} else {
						count = 0;
					}
					if (count > 2) {
						ans = "Yes";
					} 
				}

				System.out.println(ans);
			} catch (Exception e) {
				// TODO: handle exception
			} catch (Exception e) {
				// TODO: handle exception
			} Exception e {
				// TODO: handle exception
			} {
				int N = sc.nextInt();
				int a = 0;
				int b = 0;
				int count = 0;
				String ans = "No";
				for (int i = 0; i < N; i++) {
					a = sc.nextInt();
					b = sc.nextInt();

					if (count == 0 && a == b) {
						count = 1;
					} else if (count > 0 && a == b) {
						count++;
					} else {
						count = 0;
					}
					if (count > 2) {
						ans = "Yes";
					} 
				}

				System.out.println(ans);
			} 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 a = 0; a 0 int b = 0; b 0 int count = 0; count 0 String ans = "No"; ans "No" for (int i = 0; i < N; i++) {
					a = sc.nextInt();
					b = sc.nextInt();

					if (count == 0 && a == b) {
						count = 1;
					} else if (count > 0 && a == b) {
						count++;
					} else {
						count = 0;
					}
					if (count > 2) {
						ans = "Yes";
					} 
				} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
					a = sc.nextInt();
					b = sc.nextInt();

					if (count == 0 && a == b) {
						count = 1;
					} else if (count > 0 && a == b) {
						count++;
					} else {
						count = 0;
					}
					if (count > 2) {
						ans = "Yes";
					} 
				} {
					a = sc.nextInt();
					b = sc.nextInt();

					if (count == 0 && a == b) {
						count = 1;
					} else if (count > 0 && a == b) {
						count++;
					} else {
						count = 0;
					}
					if (count > 2) {
						ans = "Yes";
					} 
				} a = sc.nextInt() a sc.nextInt() sc.nextInt sc b = sc.nextInt() b sc.nextInt() sc.nextInt sc if (count == 0 && a == b) {
						count = 1;
					} else if (count > 0 && a == b) {
						count++;
					} else {
						count = 0;
					} count == 0 && a == b count == 0 count 0 a == b a b {
						count = 1;
					} count = 1 count 1 if (count > 0 && a == b) {
						count++;
					} else {
						count = 0;
					} count > 0 && a == b count > 0 count 0 a == b a b {
						count++;
					} count++ count {
						count = 0;
					} count = 0 count 0 if (count > 2) {
						ans = "Yes";
					} count > 2 count 2 {
						ans = "Yes";
					} ans = "Yes" ans "Yes" System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {

		public static void main(String[] args) {
			// TODO Auto-generated method stub
			try (Scanner sc = new Scanner(System.in)) {
				int N = sc.nextInt();
				int a = 0;
				int b = 0;
				int count = 0;
				String ans = "No";
				for (int i = 0; i < N; i++) {
					a = sc.nextInt();
					b = sc.nextInt();

					if (count == 0 && a == b) {
						count = 1;
					} else if (count > 0 && a == b) {
						count++;
					} else {
						count = 0;
					}
					if (count > 2) {
						ans = "Yes";
					} 
				}

				System.out.println(ans);
			} catch (Exception e) {
				// TODO: handle exception
			}
		}
} public class Main {

		public static void main(String[] args) {
			// TODO Auto-generated method stub
			try (Scanner sc = new Scanner(System.in)) {
				int N = sc.nextInt();
				int a = 0;
				int b = 0;
				int count = 0;
				String ans = "No";
				for (int i = 0; i < N; i++) {
					a = sc.nextInt();
					b = sc.nextInt();

					if (count == 0 && a == b) {
						count = 1;
					} else if (count > 0 && a == b) {
						count++;
					} else {
						count = 0;
					}
					if (count > 2) {
						ans = "Yes";
					} 
				}

				System.out.println(ans);
			} catch (Exception e) {
				// TODO: handle exception
			}
		}
} Main
import java.util.Scanner;

public class Main {

		public static void main(String[] args) {
			// TODO Auto-generated method stub
			try (Scanner sc = new Scanner(System.in)) {
				int N = sc.nextInt();
				int a = 0;
				int b = 0;
				int count = 0;
				String ans = "No";
				for (int i = 0; i < N; i++) {
					a = sc.nextInt();
					b = sc.nextInt();

					if (count == 0 && a == b) {
						count = 1;
					} else if (count > 0 && a == b) {
						count++;
					} else {
						count = 0;
					}
					if (count > 2) {
						ans = "Yes";
					} 
				}

				System.out.println(ans);
			} catch (Exception e) {
				// TODO: handle exception
			}
		}
}