import java.util.Scanner;

class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int d1 = 0;
        int d2 = 0;
        boolean[] boo = new boolean[n];
        boolean result = false;

        for(int i = 0; i < n; i++){
            d1 = sc.nextInt();
            d2 = sc.nextInt();

            if(d1 == d2){
                boo[i] = true;
            }
            else{
                boo[i] = false;
            }
        }

        for(int i = 0; i < n-2; i++){
            if(boo[i] && boo[i+1] && boo[i+2]){
                result = true;
            }
        }

        if(result == true){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    }    
} import java.util.Scanner; Scanner java.util class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int d1 = 0;
        int d2 = 0;
        boolean[] boo = new boolean[n];
        boolean result = false;

        for(int i = 0; i < n; i++){
            d1 = sc.nextInt();
            d2 = sc.nextInt();

            if(d1 == d2){
                boo[i] = true;
            }
            else{
                boo[i] = false;
            }
        }

        for(int i = 0; i < n-2; i++){
            if(boo[i] && boo[i+1] && boo[i+2]){
                result = true;
            }
        }

        if(result == true){
            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 d1 = 0;
        int d2 = 0;
        boolean[] boo = new boolean[n];
        boolean result = false;

        for(int i = 0; i < n; i++){
            d1 = sc.nextInt();
            d2 = sc.nextInt();

            if(d1 == d2){
                boo[i] = true;
            }
            else{
                boo[i] = false;
            }
        }

        for(int i = 0; i < n-2; i++){
            if(boo[i] && boo[i+1] && boo[i+2]){
                result = true;
            }
        }

        if(result == true){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    } main {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int d1 = 0;
        int d2 = 0;
        boolean[] boo = new boolean[n];
        boolean result = false;

        for(int i = 0; i < n; i++){
            d1 = sc.nextInt();
            d2 = sc.nextInt();

            if(d1 == d2){
                boo[i] = true;
            }
            else{
                boo[i] = false;
            }
        }

        for(int i = 0; i < n-2; i++){
            if(boo[i] && boo[i+1] && boo[i+2]){
                result = true;
            }
        }

        if(result == true){
            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 d1 = 0; d1 0 int d2 = 0; d2 0 boolean[] boo = new boolean[n]; boo new boolean[n] n boolean result = false; result false for(int i = 0; i < n; i++){
            d1 = sc.nextInt();
            d2 = sc.nextInt();

            if(d1 == d2){
                boo[i] = true;
            }
            else{
                boo[i] = false;
            }
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            d1 = sc.nextInt();
            d2 = sc.nextInt();

            if(d1 == d2){
                boo[i] = true;
            }
            else{
                boo[i] = false;
            }
        } {
            d1 = sc.nextInt();
            d2 = sc.nextInt();

            if(d1 == d2){
                boo[i] = true;
            }
            else{
                boo[i] = false;
            }
        } d1 = sc.nextInt() d1 sc.nextInt() sc.nextInt sc d2 = sc.nextInt() d2 sc.nextInt() sc.nextInt sc if(d1 == d2){
                boo[i] = true;
            }
            else{
                boo[i] = false;
            } d1 == d2 d1 d2 {
                boo[i] = true;
            } boo[i] = true boo[i] boo i true {
                boo[i] = false;
            } boo[i] = false boo[i] boo i false for(int i = 0; i < n-2; i++){
            if(boo[i] && boo[i+1] && boo[i+2]){
                result = true;
            }
        } int i = 0; int i = 0; i 0 i < n-2 i n-2 n 2 i++ i++ i {
            if(boo[i] && boo[i+1] && boo[i+2]){
                result = true;
            }
        } {
            if(boo[i] && boo[i+1] && boo[i+2]){
                result = true;
            }
        } if(boo[i] && boo[i+1] && boo[i+2]){
                result = true;
            } boo[i] && boo[i+1] && boo[i+2] boo[i] && boo[i+1] && boo[i+2] boo[i] boo i boo[i+1] boo i+1 i 1 boo[i+2] boo i+2 i 2 {
                result = true;
            } result = true result true if(result == true){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        } result == true result true {
            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
import java.util.Scanner;

class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int d1 = 0;
        int d2 = 0;
        boolean[] boo = new boolean[n];
        boolean result = false;

        for(int i = 0; i < n; i++){
            d1 = sc.nextInt();
            d2 = sc.nextInt();

            if(d1 == d2){
                boo[i] = true;
            }
            else{
                boo[i] = false;
            }
        }

        for(int i = 0; i < n-2; i++){
            if(boo[i] && boo[i+1] && boo[i+2]){
                result = true;
            }
        }

        if(result == true){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    }    
}