import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
        int attempt = in.nextInt();
        int[][] diceArr = new int[attempt][2];
        for (int i = 0; i < attempt; i++) {
            diceArr[i][0] = in.nextInt();
            diceArr[i][1] = in.nextInt();
        }
        int counter = 0;
        for (int i = 0; i < attempt; i++) {
            if (counter == 3) {
                break;
            } else if (diceArr[i][0] == diceArr[i][1]) {
                counter++;
            } else {
                counter = 0;
            }
        }
        if (counter >= 3) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        
        in.close();
    }
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
        int attempt = in.nextInt();
        int[][] diceArr = new int[attempt][2];
        for (int i = 0; i < attempt; i++) {
            diceArr[i][0] = in.nextInt();
            diceArr[i][1] = in.nextInt();
        }
        int counter = 0;
        for (int i = 0; i < attempt; i++) {
            if (counter == 3) {
                break;
            } else if (diceArr[i][0] == diceArr[i][1]) {
                counter++;
            } else {
                counter = 0;
            }
        }
        if (counter >= 3) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        
        in.close();
    }
} Main public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
        int attempt = in.nextInt();
        int[][] diceArr = new int[attempt][2];
        for (int i = 0; i < attempt; i++) {
            diceArr[i][0] = in.nextInt();
            diceArr[i][1] = in.nextInt();
        }
        int counter = 0;
        for (int i = 0; i < attempt; i++) {
            if (counter == 3) {
                break;
            } else if (diceArr[i][0] == diceArr[i][1]) {
                counter++;
            } else {
                counter = 0;
            }
        }
        if (counter >= 3) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        
        in.close();
    } main {
		Scanner in = new Scanner(System.in);
        int attempt = in.nextInt();
        int[][] diceArr = new int[attempt][2];
        for (int i = 0; i < attempt; i++) {
            diceArr[i][0] = in.nextInt();
            diceArr[i][1] = in.nextInt();
        }
        int counter = 0;
        for (int i = 0; i < attempt; i++) {
            if (counter == 3) {
                break;
            } else if (diceArr[i][0] == diceArr[i][1]) {
                counter++;
            } else {
                counter = 0;
            }
        }
        if (counter >= 3) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        
        in.close();
    } Scanner in = new Scanner(System.in); in new Scanner(System.in) int attempt = in.nextInt(); attempt in.nextInt() in.nextInt in int[][] diceArr = new int[attempt][2]; diceArr new int[attempt][2] attempt 2 for (int i = 0; i < attempt; i++) {
            diceArr[i][0] = in.nextInt();
            diceArr[i][1] = in.nextInt();
        } int i = 0; int i = 0; i 0 i < attempt i attempt i++ i++ i {
            diceArr[i][0] = in.nextInt();
            diceArr[i][1] = in.nextInt();
        } {
            diceArr[i][0] = in.nextInt();
            diceArr[i][1] = in.nextInt();
        } diceArr[i][0] = in.nextInt() diceArr[i][0] diceArr[i] diceArr i 0 in.nextInt() in.nextInt in diceArr[i][1] = in.nextInt() diceArr[i][1] diceArr[i] diceArr i 1 in.nextInt() in.nextInt in int counter = 0; counter 0 for (int i = 0; i < attempt; i++) {
            if (counter == 3) {
                break;
            } else if (diceArr[i][0] == diceArr[i][1]) {
                counter++;
            } else {
                counter = 0;
            }
        } int i = 0; int i = 0; i 0 i < attempt i attempt i++ i++ i {
            if (counter == 3) {
                break;
            } else if (diceArr[i][0] == diceArr[i][1]) {
                counter++;
            } else {
                counter = 0;
            }
        } {
            if (counter == 3) {
                break;
            } else if (diceArr[i][0] == diceArr[i][1]) {
                counter++;
            } else {
                counter = 0;
            }
        } if (counter == 3) {
                break;
            } else if (diceArr[i][0] == diceArr[i][1]) {
                counter++;
            } else {
                counter = 0;
            } counter == 3 counter 3 {
                break;
            } break; if (diceArr[i][0] == diceArr[i][1]) {
                counter++;
            } else {
                counter = 0;
            } diceArr[i][0] == diceArr[i][1] diceArr[i][0] diceArr[i] diceArr i 0 diceArr[i][1] diceArr[i] diceArr i 1 {
                counter++;
            } counter++ counter {
                counter = 0;
            } counter = 0 counter 0 if (counter >= 3) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        } counter >= 3 counter 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" in.close() in.close in String[] args args public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
        int attempt = in.nextInt();
        int[][] diceArr = new int[attempt][2];
        for (int i = 0; i < attempt; i++) {
            diceArr[i][0] = in.nextInt();
            diceArr[i][1] = in.nextInt();
        }
        int counter = 0;
        for (int i = 0; i < attempt; i++) {
            if (counter == 3) {
                break;
            } else if (diceArr[i][0] == diceArr[i][1]) {
                counter++;
            } else {
                counter = 0;
            }
        }
        if (counter >= 3) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        
        in.close();
    }
} public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
        int attempt = in.nextInt();
        int[][] diceArr = new int[attempt][2];
        for (int i = 0; i < attempt; i++) {
            diceArr[i][0] = in.nextInt();
            diceArr[i][1] = in.nextInt();
        }
        int counter = 0;
        for (int i = 0; i < attempt; i++) {
            if (counter == 3) {
                break;
            } else if (diceArr[i][0] == diceArr[i][1]) {
                counter++;
            } else {
                counter = 0;
            }
        }
        if (counter >= 3) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        
        in.close();
    }
} Main
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
        int attempt = in.nextInt();
        int[][] diceArr = new int[attempt][2];
        for (int i = 0; i < attempt; i++) {
            diceArr[i][0] = in.nextInt();
            diceArr[i][1] = in.nextInt();
        }
        int counter = 0;
        for (int i = 0; i < attempt; i++) {
            if (counter == 3) {
                break;
            } else if (diceArr[i][0] == diceArr[i][1]) {
                counter++;
            } else {
                counter = 0;
            }
        }
        if (counter >= 3) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        
        in.close();
    }
}