import java.util.Scanner;
import java.util.Arrays;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] dice = new int[2][n];
        for(int i = 0; i<n; i++){
            dice[0][i] = sc.nextInt();
            dice[1][i] = sc.nextInt();
        }

        int[] count = new int[n-2];
        for(int i = 0; i<n-2; i++){
            for(int j = i; j<i+3; j++){
                if(dice[0][j] == dice[1][j]){
                    count[i]++;
                }
            }
        }

        Arrays.sort(count);
        if(count[n-3] == 3){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    }
} import java.util.Scanner; Scanner java.util import java.util.Arrays; Arrays java.util public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] dice = new int[2][n];
        for(int i = 0; i<n; i++){
            dice[0][i] = sc.nextInt();
            dice[1][i] = sc.nextInt();
        }

        int[] count = new int[n-2];
        for(int i = 0; i<n-2; i++){
            for(int j = i; j<i+3; j++){
                if(dice[0][j] == dice[1][j]){
                    count[i]++;
                }
            }
        }

        Arrays.sort(count);
        if(count[n-3] == 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[][] dice = new int[2][n];
        for(int i = 0; i<n; i++){
            dice[0][i] = sc.nextInt();
            dice[1][i] = sc.nextInt();
        }

        int[] count = new int[n-2];
        for(int i = 0; i<n-2; i++){
            for(int j = i; j<i+3; j++){
                if(dice[0][j] == dice[1][j]){
                    count[i]++;
                }
            }
        }

        Arrays.sort(count);
        if(count[n-3] == 3){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] dice = new int[2][n];
        for(int i = 0; i<n; i++){
            dice[0][i] = sc.nextInt();
            dice[1][i] = sc.nextInt();
        }

        int[] count = new int[n-2];
        for(int i = 0; i<n-2; i++){
            for(int j = i; j<i+3; j++){
                if(dice[0][j] == dice[1][j]){
                    count[i]++;
                }
            }
        }

        Arrays.sort(count);
        if(count[n-3] == 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[][] dice = new int[2][n]; dice new int[2][n] 2 n for(int i = 0; i<n; i++){
            dice[0][i] = sc.nextInt();
            dice[1][i] = sc.nextInt();
        } int i = 0; int i = 0; i 0 i<n i n i++ i++ i {
            dice[0][i] = sc.nextInt();
            dice[1][i] = sc.nextInt();
        } {
            dice[0][i] = sc.nextInt();
            dice[1][i] = sc.nextInt();
        } dice[0][i] = sc.nextInt() dice[0][i] dice[0] dice 0 i sc.nextInt() sc.nextInt sc dice[1][i] = sc.nextInt() dice[1][i] dice[1] dice 1 i sc.nextInt() sc.nextInt sc int[] count = new int[n-2]; count new int[n-2] n-2 n 2 for(int i = 0; i<n-2; i++){
            for(int j = i; j<i+3; j++){
                if(dice[0][j] == dice[1][j]){
                    count[i]++;
                }
            }
        } int i = 0; int i = 0; i 0 i<n-2 i n-2 n 2 i++ i++ i {
            for(int j = i; j<i+3; j++){
                if(dice[0][j] == dice[1][j]){
                    count[i]++;
                }
            }
        } {
            for(int j = i; j<i+3; j++){
                if(dice[0][j] == dice[1][j]){
                    count[i]++;
                }
            }
        } for(int j = i; j<i+3; j++){
                if(dice[0][j] == dice[1][j]){
                    count[i]++;
                }
            } int j = i; int j = i; j i j<i+3 j i+3 i 3 j++ j++ j {
                if(dice[0][j] == dice[1][j]){
                    count[i]++;
                }
            } {
                if(dice[0][j] == dice[1][j]){
                    count[i]++;
                }
            } if(dice[0][j] == dice[1][j]){
                    count[i]++;
                } dice[0][j] == dice[1][j] dice[0][j] dice[0] dice 0 j dice[1][j] dice[1] dice 1 j {
                    count[i]++;
                } count[i]++ count[i] count i Arrays.sort(count) Arrays.sort Arrays count if(count[n-3] == 3){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        } count[n-3] == 3 count[n-3] count n-3 n 3 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" String[] args args public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] dice = new int[2][n];
        for(int i = 0; i<n; i++){
            dice[0][i] = sc.nextInt();
            dice[1][i] = sc.nextInt();
        }

        int[] count = new int[n-2];
        for(int i = 0; i<n-2; i++){
            for(int j = i; j<i+3; j++){
                if(dice[0][j] == dice[1][j]){
                    count[i]++;
                }
            }
        }

        Arrays.sort(count);
        if(count[n-3] == 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[][] dice = new int[2][n];
        for(int i = 0; i<n; i++){
            dice[0][i] = sc.nextInt();
            dice[1][i] = sc.nextInt();
        }

        int[] count = new int[n-2];
        for(int i = 0; i<n-2; i++){
            for(int j = i; j<i+3; j++){
                if(dice[0][j] == dice[1][j]){
                    count[i]++;
                }
            }
        }

        Arrays.sort(count);
        if(count[n-3] == 3){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    }
} Main
import java.util.Scanner;
import java.util.Arrays;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] dice = new int[2][n];
        for(int i = 0; i<n; i++){
            dice[0][i] = sc.nextInt();
            dice[1][i] = sc.nextInt();
        }

        int[] count = new int[n-2];
        for(int i = 0; i<n-2; i++){
            for(int j = i; j<i+3; j++){
                if(dice[0][j] == dice[1][j]){
                    count[i]++;
                }
            }
        }

        Arrays.sort(count);
        if(count[n-3] == 3){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    }
}