import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	int[][] D;

	Main(BufferedReader in) throws IOException {
		int N = Integer.parseInt(in.readLine());
		D = new int[N][2];
		for (int i = 0; i < N; ++i) {
			String[] tokens = in.readLine().split(" ");
			D[i][0] = Integer.parseInt(tokens[0]);
			D[i][1] = Integer.parseInt(tokens[1]);
		}

		boolean result = false;
		for (int i = 0; i + 2 < N; ++i) {
			if (check(i)) {
				result = true;
				break;
			}
		}
		if (result) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

	boolean check(int i) {
		if (isSame(i) && isSame(i + 1) && isSame(i + 2)) {
			return true;
		} else {
			return false;
		}
	}

	boolean isSame(int i) {
		if (D[i][0] == D[i][1]) {
			return true;
		} else {
			return false;
		}
	}

	void calc() {
	}

	void showResult() {
	}
} import java.util.*; util.* java import java.io.*; io.* java import java.nio.charset.StandardCharsets; StandardCharsets java.nio.charset public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	int[][] D;

	Main(BufferedReader in) throws IOException {
		int N = Integer.parseInt(in.readLine());
		D = new int[N][2];
		for (int i = 0; i < N; ++i) {
			String[] tokens = in.readLine().split(" ");
			D[i][0] = Integer.parseInt(tokens[0]);
			D[i][1] = Integer.parseInt(tokens[1]);
		}

		boolean result = false;
		for (int i = 0; i + 2 < N; ++i) {
			if (check(i)) {
				result = true;
				break;
			}
		}
		if (result) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

	boolean check(int i) {
		if (isSame(i) && isSame(i + 1) && isSame(i + 2)) {
			return true;
		} else {
			return false;
		}
	}

	boolean isSame(int i) {
		if (D[i][0] == D[i][1]) {
			return true;
		} else {
			return false;
		}
	}

	void calc() {
	}

	void showResult() {
	}
} Main int[][] D; D public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	} main {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	} InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8); reader new InputStreamReader(System.in, StandardCharsets.UTF_8) BufferedReader in = new BufferedReader(reader); in new BufferedReader(reader) Main ins = new Main(in); ins new Main(in) ins.calc() ins.calc ins ins.showResult() ins.showResult ins String[] args args Main(BufferedReader in) throws IOException {
		int N = Integer.parseInt(in.readLine());
		D = new int[N][2];
		for (int i = 0; i < N; ++i) {
			String[] tokens = in.readLine().split(" ");
			D[i][0] = Integer.parseInt(tokens[0]);
			D[i][1] = Integer.parseInt(tokens[1]);
		}

		boolean result = false;
		for (int i = 0; i + 2 < N; ++i) {
			if (check(i)) {
				result = true;
				break;
			}
		}
		if (result) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	} Main {
		int N = Integer.parseInt(in.readLine());
		D = new int[N][2];
		for (int i = 0; i < N; ++i) {
			String[] tokens = in.readLine().split(" ");
			D[i][0] = Integer.parseInt(tokens[0]);
			D[i][1] = Integer.parseInt(tokens[1]);
		}

		boolean result = false;
		for (int i = 0; i + 2 < N; ++i) {
			if (check(i)) {
				result = true;
				break;
			}
		}
		if (result) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	} int N = Integer.parseInt(in.readLine()); N Integer.parseInt(in.readLine()) Integer.parseInt Integer in.readLine() in.readLine in D = new int[N][2] D new int[N][2] N 2 for (int i = 0; i < N; ++i) {
			String[] tokens = in.readLine().split(" ");
			D[i][0] = Integer.parseInt(tokens[0]);
			D[i][1] = Integer.parseInt(tokens[1]);
		} int i = 0; int i = 0; i 0 i < N i N ++i ++i i {
			String[] tokens = in.readLine().split(" ");
			D[i][0] = Integer.parseInt(tokens[0]);
			D[i][1] = Integer.parseInt(tokens[1]);
		} {
			String[] tokens = in.readLine().split(" ");
			D[i][0] = Integer.parseInt(tokens[0]);
			D[i][1] = Integer.parseInt(tokens[1]);
		} String[] tokens = in.readLine().split(" "); tokens in.readLine().split(" ") in.readLine().split in.readLine() in.readLine in " " D[i][0] = Integer.parseInt(tokens[0]) D[i][0] D[i] D i 0 Integer.parseInt(tokens[0]) Integer.parseInt Integer tokens[0] tokens 0 D[i][1] = Integer.parseInt(tokens[1]) D[i][1] D[i] D i 1 Integer.parseInt(tokens[1]) Integer.parseInt Integer tokens[1] tokens 1 boolean result = false; result false for (int i = 0; i + 2 < N; ++i) {
			if (check(i)) {
				result = true;
				break;
			}
		} int i = 0; int i = 0; i 0 i + 2 < N i + 2 i 2 N ++i ++i i {
			if (check(i)) {
				result = true;
				break;
			}
		} {
			if (check(i)) {
				result = true;
				break;
			}
		} if (check(i)) {
				result = true;
				break;
			} check(i) check i {
				result = true;
				break;
			} result = true result true break; if (result) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		} result {
			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" BufferedReader in in boolean check(int i) {
		if (isSame(i) && isSame(i + 1) && isSame(i + 2)) {
			return true;
		} else {
			return false;
		}
	} check {
		if (isSame(i) && isSame(i + 1) && isSame(i + 2)) {
			return true;
		} else {
			return false;
		}
	} if (isSame(i) && isSame(i + 1) && isSame(i + 2)) {
			return true;
		} else {
			return false;
		} isSame(i) && isSame(i + 1) && isSame(i + 2) isSame(i) && isSame(i + 1) && isSame(i + 2) isSame(i) isSame i isSame(i + 1) isSame i + 1 i 1 isSame(i + 2) isSame i + 2 i 2 {
			return true;
		} return true; true {
			return false;
		} return false; false int i i boolean isSame(int i) {
		if (D[i][0] == D[i][1]) {
			return true;
		} else {
			return false;
		}
	} isSame {
		if (D[i][0] == D[i][1]) {
			return true;
		} else {
			return false;
		}
	} if (D[i][0] == D[i][1]) {
			return true;
		} else {
			return false;
		} D[i][0] == D[i][1] D[i][0] D[i] D i 0 D[i][1] D[i] D i 1 {
			return true;
		} return true; true {
			return false;
		} return false; false int i i void calc() {
	} calc {
	} void showResult() {
	} showResult {
	} public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	int[][] D;

	Main(BufferedReader in) throws IOException {
		int N = Integer.parseInt(in.readLine());
		D = new int[N][2];
		for (int i = 0; i < N; ++i) {
			String[] tokens = in.readLine().split(" ");
			D[i][0] = Integer.parseInt(tokens[0]);
			D[i][1] = Integer.parseInt(tokens[1]);
		}

		boolean result = false;
		for (int i = 0; i + 2 < N; ++i) {
			if (check(i)) {
				result = true;
				break;
			}
		}
		if (result) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

	boolean check(int i) {
		if (isSame(i) && isSame(i + 1) && isSame(i + 2)) {
			return true;
		} else {
			return false;
		}
	}

	boolean isSame(int i) {
		if (D[i][0] == D[i][1]) {
			return true;
		} else {
			return false;
		}
	}

	void calc() {
	}

	void showResult() {
	}
} public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	int[][] D;

	Main(BufferedReader in) throws IOException {
		int N = Integer.parseInt(in.readLine());
		D = new int[N][2];
		for (int i = 0; i < N; ++i) {
			String[] tokens = in.readLine().split(" ");
			D[i][0] = Integer.parseInt(tokens[0]);
			D[i][1] = Integer.parseInt(tokens[1]);
		}

		boolean result = false;
		for (int i = 0; i + 2 < N; ++i) {
			if (check(i)) {
				result = true;
				break;
			}
		}
		if (result) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

	boolean check(int i) {
		if (isSame(i) && isSame(i + 1) && isSame(i + 2)) {
			return true;
		} else {
			return false;
		}
	}

	boolean isSame(int i) {
		if (D[i][0] == D[i][1]) {
			return true;
		} else {
			return false;
		}
	}

	void calc() {
	}

	void showResult() {
	}
} Main
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	int[][] D;

	Main(BufferedReader in) throws IOException {
		int N = Integer.parseInt(in.readLine());
		D = new int[N][2];
		for (int i = 0; i < N; ++i) {
			String[] tokens = in.readLine().split(" ");
			D[i][0] = Integer.parseInt(tokens[0]);
			D[i][1] = Integer.parseInt(tokens[1]);
		}

		boolean result = false;
		for (int i = 0; i + 2 < N; ++i) {
			if (check(i)) {
				result = true;
				break;
			}
		}
		if (result) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

	boolean check(int i) {
		if (isSame(i) && isSame(i + 1) && isSame(i + 2)) {
			return true;
		} else {
			return false;
		}
	}

	boolean isSame(int i) {
		if (D[i][0] == D[i][1]) {
			return true;
		} else {
			return false;
		}
	}

	void calc() {
	}

	void showResult() {
	}
}