import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
    
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new java.io.InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        StringTokenizer st = new StringTokenizer(br.readLine());

        int N = Integer.parseInt(st.nextToken());

        int counter = 0;
        boolean ansFlag = false;

        for(int i = 0; i < N; i++) {
            String[] input_array = br.readLine().split(" ");
            if(input_array[0].equals(input_array[1])) {
                counter += 1;
            } else {
                counter = 0;
            }

            if(counter == 3) {
                ansFlag = true;
            }
        }

        if(ansFlag){
            pw.println("Yes");
        } else {
            pw.println("No");
        }

        br.close();
        pw.close();
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.PrintWriter; PrintWriter java.io import java.util.Arrays; Arrays java.util import java.util.StringTokenizer; StringTokenizer java.util public class Main {
    
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new java.io.InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        StringTokenizer st = new StringTokenizer(br.readLine());

        int N = Integer.parseInt(st.nextToken());

        int counter = 0;
        boolean ansFlag = false;

        for(int i = 0; i < N; i++) {
            String[] input_array = br.readLine().split(" ");
            if(input_array[0].equals(input_array[1])) {
                counter += 1;
            } else {
                counter = 0;
            }

            if(counter == 3) {
                ansFlag = true;
            }
        }

        if(ansFlag){
            pw.println("Yes");
        } else {
            pw.println("No");
        }

        br.close();
        pw.close();
    }
} Main public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new java.io.InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        StringTokenizer st = new StringTokenizer(br.readLine());

        int N = Integer.parseInt(st.nextToken());

        int counter = 0;
        boolean ansFlag = false;

        for(int i = 0; i < N; i++) {
            String[] input_array = br.readLine().split(" ");
            if(input_array[0].equals(input_array[1])) {
                counter += 1;
            } else {
                counter = 0;
            }

            if(counter == 3) {
                ansFlag = true;
            }
        }

        if(ansFlag){
            pw.println("Yes");
        } else {
            pw.println("No");
        }

        br.close();
        pw.close();
    } main {
        BufferedReader br = new BufferedReader(new java.io.InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        StringTokenizer st = new StringTokenizer(br.readLine());

        int N = Integer.parseInt(st.nextToken());

        int counter = 0;
        boolean ansFlag = false;

        for(int i = 0; i < N; i++) {
            String[] input_array = br.readLine().split(" ");
            if(input_array[0].equals(input_array[1])) {
                counter += 1;
            } else {
                counter = 0;
            }

            if(counter == 3) {
                ansFlag = true;
            }
        }

        if(ansFlag){
            pw.println("Yes");
        } else {
            pw.println("No");
        }

        br.close();
        pw.close();
    } BufferedReader br = new BufferedReader(new java.io.InputStreamReader(System.in)); br new BufferedReader(new java.io.InputStreamReader(System.in)) PrintWriter pw = new PrintWriter(System.out); pw new PrintWriter(System.out) StringTokenizer st = new StringTokenizer(br.readLine()); st new StringTokenizer(br.readLine()) int N = Integer.parseInt(st.nextToken()); N Integer.parseInt(st.nextToken()) Integer.parseInt Integer st.nextToken() st.nextToken st int counter = 0; counter 0 boolean ansFlag = false; ansFlag false for(int i = 0; i < N; i++) {
            String[] input_array = br.readLine().split(" ");
            if(input_array[0].equals(input_array[1])) {
                counter += 1;
            } else {
                counter = 0;
            }

            if(counter == 3) {
                ansFlag = true;
            }
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            String[] input_array = br.readLine().split(" ");
            if(input_array[0].equals(input_array[1])) {
                counter += 1;
            } else {
                counter = 0;
            }

            if(counter == 3) {
                ansFlag = true;
            }
        } {
            String[] input_array = br.readLine().split(" ");
            if(input_array[0].equals(input_array[1])) {
                counter += 1;
            } else {
                counter = 0;
            }

            if(counter == 3) {
                ansFlag = true;
            }
        } String[] input_array = br.readLine().split(" "); input_array br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " if(input_array[0].equals(input_array[1])) {
                counter += 1;
            } else {
                counter = 0;
            } input_array[0].equals(input_array[1]) input_array[0].equals input_array[0] input_array 0 input_array[1] input_array 1 {
                counter += 1;
            } counter += 1 counter 1 {
                counter = 0;
            } counter = 0 counter 0 if(counter == 3) {
                ansFlag = true;
            } counter == 3 counter 3 {
                ansFlag = true;
            } ansFlag = true ansFlag true if(ansFlag){
            pw.println("Yes");
        } else {
            pw.println("No");
        } ansFlag {
            pw.println("Yes");
        } pw.println("Yes") pw.println pw "Yes" {
            pw.println("No");
        } pw.println("No") pw.println pw "No" br.close() br.close br pw.close() pw.close pw String[] args args public class Main {
    
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new java.io.InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        StringTokenizer st = new StringTokenizer(br.readLine());

        int N = Integer.parseInt(st.nextToken());

        int counter = 0;
        boolean ansFlag = false;

        for(int i = 0; i < N; i++) {
            String[] input_array = br.readLine().split(" ");
            if(input_array[0].equals(input_array[1])) {
                counter += 1;
            } else {
                counter = 0;
            }

            if(counter == 3) {
                ansFlag = true;
            }
        }

        if(ansFlag){
            pw.println("Yes");
        } else {
            pw.println("No");
        }

        br.close();
        pw.close();
    }
} public class Main {
    
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new java.io.InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        StringTokenizer st = new StringTokenizer(br.readLine());

        int N = Integer.parseInt(st.nextToken());

        int counter = 0;
        boolean ansFlag = false;

        for(int i = 0; i < N; i++) {
            String[] input_array = br.readLine().split(" ");
            if(input_array[0].equals(input_array[1])) {
                counter += 1;
            } else {
                counter = 0;
            }

            if(counter == 3) {
                ansFlag = true;
            }
        }

        if(ansFlag){
            pw.println("Yes");
        } else {
            pw.println("No");
        }

        br.close();
        pw.close();
    }
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
    
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new java.io.InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        StringTokenizer st = new StringTokenizer(br.readLine());

        int N = Integer.parseInt(st.nextToken());

        int counter = 0;
        boolean ansFlag = false;

        for(int i = 0; i < N; i++) {
            String[] input_array = br.readLine().split(" ");
            if(input_array[0].equals(input_array[1])) {
                counter += 1;
            } else {
                counter = 0;
            }

            if(counter == 3) {
                ansFlag = true;
            }
        }

        if(ansFlag){
            pw.println("Yes");
        } else {
            pw.println("No");
        }

        br.close();
        pw.close();
    }
}