import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] x = new int[N];
		int[] y = new int[N];
		int maxc = 0;
		int c = 0;
		for (int i = 0; i < N; i++) {
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
			if (x[i] == y[i]) {
				c++;
			} else {
				if (c > maxc)
					maxc = c;
				c = 0;
			}
		}
		if (maxc >= 3 || c >= 3)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
} import java.util.*; util.* java import java.io.*; io.* java public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] x = new int[N];
		int[] y = new int[N];
		int maxc = 0;
		int c = 0;
		for (int i = 0; i < N; i++) {
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
			if (x[i] == y[i]) {
				c++;
			} else {
				if (c > maxc)
					maxc = c;
				c = 0;
			}
		}
		if (maxc >= 3 || c >= 3)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] x = new int[N];
		int[] y = new int[N];
		int maxc = 0;
		int c = 0;
		for (int i = 0; i < N; i++) {
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
			if (x[i] == y[i]) {
				c++;
			} else {
				if (c > maxc)
					maxc = c;
				c = 0;
			}
		}
		if (maxc >= 3 || c >= 3)
			System.out.println("Yes");
		else
			System.out.println("No");
	} main {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] x = new int[N];
		int[] y = new int[N];
		int maxc = 0;
		int c = 0;
		for (int i = 0; i < N; i++) {
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
			if (x[i] == y[i]) {
				c++;
			} else {
				if (c > maxc)
					maxc = c;
				c = 0;
			}
		}
		if (maxc >= 3 || c >= 3)
			System.out.println("Yes");
		else
			System.out.println("No");
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int[] x = new int[N]; x new int[N] N int[] y = new int[N]; y new int[N] N int maxc = 0; maxc 0 int c = 0; c 0 for (int i = 0; i < N; i++) {
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
			if (x[i] == y[i]) {
				c++;
			} else {
				if (c > maxc)
					maxc = c;
				c = 0;
			}
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
			if (x[i] == y[i]) {
				c++;
			} else {
				if (c > maxc)
					maxc = c;
				c = 0;
			}
		} {
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
			if (x[i] == y[i]) {
				c++;
			} else {
				if (c > maxc)
					maxc = c;
				c = 0;
			}
		} x[i] = sc.nextInt() x[i] x i sc.nextInt() sc.nextInt sc y[i] = sc.nextInt() y[i] y i sc.nextInt() sc.nextInt sc if (x[i] == y[i]) {
				c++;
			} else {
				if (c > maxc)
					maxc = c;
				c = 0;
			} x[i] == y[i] x[i] x i y[i] y i {
				c++;
			} c++ c {
				if (c > maxc)
					maxc = c;
				c = 0;
			} if (c > maxc)
					maxc = c; c > maxc c maxc maxc = c maxc c c = 0 c 0 if (maxc >= 3 || c >= 3)
			System.out.println("Yes");
		else
			System.out.println("No"); maxc >= 3 || c >= 3 maxc >= 3 maxc 3 c >= 3 c 3 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" String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] x = new int[N];
		int[] y = new int[N];
		int maxc = 0;
		int c = 0;
		for (int i = 0; i < N; i++) {
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
			if (x[i] == y[i]) {
				c++;
			} else {
				if (c > maxc)
					maxc = c;
				c = 0;
			}
		}
		if (maxc >= 3 || c >= 3)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] x = new int[N];
		int[] y = new int[N];
		int maxc = 0;
		int c = 0;
		for (int i = 0; i < N; i++) {
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
			if (x[i] == y[i]) {
				c++;
			} else {
				if (c > maxc)
					maxc = c;
				c = 0;
			}
		}
		if (maxc >= 3 || c >= 3)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
} Main
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] x = new int[N];
		int[] y = new int[N];
		int maxc = 0;
		int c = 0;
		for (int i = 0; i < N; i++) {
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
			if (x[i] == y[i]) {
				c++;
			} else {
				if (c > maxc)
					maxc = c;
				c = 0;
			}
		}
		if (maxc >= 3 || c >= 3)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}