import java.util.Scanner;

public class Main {

	public static void main(final String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		boolean ret = false;
		int zorome = 0;
		for (int i = 0; i < n; i++) {
			int d1 = sc.nextInt();
			int d2 = sc.nextInt();
			if(d1 == d2) zorome++;
			else zorome = 0;
			if(zorome >= 3) ret = true;
		}
		sc.close();
		prtln(ret ? "Yes" : "No");
	}

	public static <T> void prtln(T t) { System.out.println(t); }
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(final String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		boolean ret = false;
		int zorome = 0;
		for (int i = 0; i < n; i++) {
			int d1 = sc.nextInt();
			int d2 = sc.nextInt();
			if(d1 == d2) zorome++;
			else zorome = 0;
			if(zorome >= 3) ret = true;
		}
		sc.close();
		prtln(ret ? "Yes" : "No");
	}

	public static <T> void prtln(T t) { System.out.println(t); }
} Main public static void main(final String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		boolean ret = false;
		int zorome = 0;
		for (int i = 0; i < n; i++) {
			int d1 = sc.nextInt();
			int d2 = sc.nextInt();
			if(d1 == d2) zorome++;
			else zorome = 0;
			if(zorome >= 3) ret = true;
		}
		sc.close();
		prtln(ret ? "Yes" : "No");
	} main {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		boolean ret = false;
		int zorome = 0;
		for (int i = 0; i < n; i++) {
			int d1 = sc.nextInt();
			int d2 = sc.nextInt();
			if(d1 == d2) zorome++;
			else zorome = 0;
			if(zorome >= 3) ret = true;
		}
		sc.close();
		prtln(ret ? "Yes" : "No");
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc boolean ret = false; ret false int zorome = 0; zorome 0 for (int i = 0; i < n; i++) {
			int d1 = sc.nextInt();
			int d2 = sc.nextInt();
			if(d1 == d2) zorome++;
			else zorome = 0;
			if(zorome >= 3) ret = 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) zorome++;
			else zorome = 0;
			if(zorome >= 3) ret = true;
		} {
			int d1 = sc.nextInt();
			int d2 = sc.nextInt();
			if(d1 == d2) zorome++;
			else zorome = 0;
			if(zorome >= 3) ret = true;
		} int d1 = sc.nextInt(); d1 sc.nextInt() sc.nextInt sc int d2 = sc.nextInt(); d2 sc.nextInt() sc.nextInt sc if(d1 == d2) zorome++;
			else zorome = 0; d1 == d2 d1 d2 zorome++ zorome zorome = 0 zorome 0 if(zorome >= 3) ret = true; zorome >= 3 zorome 3 ret = true ret true sc.close() sc.close sc prtln(ret ? "Yes" : "No") prtln ret ? "Yes" : "No" ret "Yes" "No" final String[] args args public static <T> void prtln(T t) { System.out.println(t); } prtln { System.out.println(t); } System.out.println(t) System.out.println System.out System System.out t T t t public class Main {

	public static void main(final String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		boolean ret = false;
		int zorome = 0;
		for (int i = 0; i < n; i++) {
			int d1 = sc.nextInt();
			int d2 = sc.nextInt();
			if(d1 == d2) zorome++;
			else zorome = 0;
			if(zorome >= 3) ret = true;
		}
		sc.close();
		prtln(ret ? "Yes" : "No");
	}

	public static <T> void prtln(T t) { System.out.println(t); }
} public class Main {

	public static void main(final String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		boolean ret = false;
		int zorome = 0;
		for (int i = 0; i < n; i++) {
			int d1 = sc.nextInt();
			int d2 = sc.nextInt();
			if(d1 == d2) zorome++;
			else zorome = 0;
			if(zorome >= 3) ret = true;
		}
		sc.close();
		prtln(ret ? "Yes" : "No");
	}

	public static <T> void prtln(T t) { System.out.println(t); }
} Main
import java.util.Scanner;

public class Main {

	public static void main(final String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		boolean ret = false;
		int zorome = 0;
		for (int i = 0; i < n; i++) {
			int d1 = sc.nextInt();
			int d2 = sc.nextInt();
			if(d1 == d2) zorome++;
			else zorome = 0;
			if(zorome >= 3) ret = true;
		}
		sc.close();
		prtln(ret ? "Yes" : "No");
	}

	public static <T> void prtln(T t) { System.out.println(t); }
}
