import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args)throws Exception {
        BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(buffer.readLine());
        int [][] ds = new int[n][2];
        for (int pos = 0; pos < n; pos++) {
            String [] inp = buffer.readLine().split(" ");
            ds[pos][0] = Integer.parseInt(inp[0]);
            ds[pos][1] = Integer.parseInt(inp[1]);
        }
        boolean check = false;
        for (int pos = 0; pos < n-2; pos++) {
            if(ds[pos][0] == ds[pos][1] && ds[pos+1][0] == ds[pos+1][1] && ds[pos+2][0] == ds[pos+2][1]){
                check = true;
                break;
            }
        }
        if (check)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
} import java.io.*; io.* java import java.util.*; util.* java public class Main {
    public static void main(String[] args)throws Exception {
        BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(buffer.readLine());
        int [][] ds = new int[n][2];
        for (int pos = 0; pos < n; pos++) {
            String [] inp = buffer.readLine().split(" ");
            ds[pos][0] = Integer.parseInt(inp[0]);
            ds[pos][1] = Integer.parseInt(inp[1]);
        }
        boolean check = false;
        for (int pos = 0; pos < n-2; pos++) {
            if(ds[pos][0] == ds[pos][1] && ds[pos+1][0] == ds[pos+1][1] && ds[pos+2][0] == ds[pos+2][1]){
                check = true;
                break;
            }
        }
        if (check)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
} Main public static void main(String[] args)throws Exception {
        BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(buffer.readLine());
        int [][] ds = new int[n][2];
        for (int pos = 0; pos < n; pos++) {
            String [] inp = buffer.readLine().split(" ");
            ds[pos][0] = Integer.parseInt(inp[0]);
            ds[pos][1] = Integer.parseInt(inp[1]);
        }
        boolean check = false;
        for (int pos = 0; pos < n-2; pos++) {
            if(ds[pos][0] == ds[pos][1] && ds[pos+1][0] == ds[pos+1][1] && ds[pos+2][0] == ds[pos+2][1]){
                check = true;
                break;
            }
        }
        if (check)
            System.out.println("Yes");
        else
            System.out.println("No");
    } main {
        BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(buffer.readLine());
        int [][] ds = new int[n][2];
        for (int pos = 0; pos < n; pos++) {
            String [] inp = buffer.readLine().split(" ");
            ds[pos][0] = Integer.parseInt(inp[0]);
            ds[pos][1] = Integer.parseInt(inp[1]);
        }
        boolean check = false;
        for (int pos = 0; pos < n-2; pos++) {
            if(ds[pos][0] == ds[pos][1] && ds[pos+1][0] == ds[pos+1][1] && ds[pos+2][0] == ds[pos+2][1]){
                check = true;
                break;
            }
        }
        if (check)
            System.out.println("Yes");
        else
            System.out.println("No");
    } BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in)); buffer new BufferedReader(new InputStreamReader(System.in)) int n = Integer.parseInt(buffer.readLine()); n Integer.parseInt(buffer.readLine()) Integer.parseInt Integer buffer.readLine() buffer.readLine buffer int [][] ds = new int[n][2]; ds new int[n][2] n 2 for (int pos = 0; pos < n; pos++) {
            String [] inp = buffer.readLine().split(" ");
            ds[pos][0] = Integer.parseInt(inp[0]);
            ds[pos][1] = Integer.parseInt(inp[1]);
        } int pos = 0; int pos = 0; pos 0 pos < n pos n pos++ pos++ pos {
            String [] inp = buffer.readLine().split(" ");
            ds[pos][0] = Integer.parseInt(inp[0]);
            ds[pos][1] = Integer.parseInt(inp[1]);
        } {
            String [] inp = buffer.readLine().split(" ");
            ds[pos][0] = Integer.parseInt(inp[0]);
            ds[pos][1] = Integer.parseInt(inp[1]);
        } String [] inp = buffer.readLine().split(" "); inp buffer.readLine().split(" ") buffer.readLine().split buffer.readLine() buffer.readLine buffer " " ds[pos][0] = Integer.parseInt(inp[0]) ds[pos][0] ds[pos] ds pos 0 Integer.parseInt(inp[0]) Integer.parseInt Integer inp[0] inp 0 ds[pos][1] = Integer.parseInt(inp[1]) ds[pos][1] ds[pos] ds pos 1 Integer.parseInt(inp[1]) Integer.parseInt Integer inp[1] inp 1 boolean check = false; check false for (int pos = 0; pos < n-2; pos++) {
            if(ds[pos][0] == ds[pos][1] && ds[pos+1][0] == ds[pos+1][1] && ds[pos+2][0] == ds[pos+2][1]){
                check = true;
                break;
            }
        } int pos = 0; int pos = 0; pos 0 pos < n-2 pos n-2 n 2 pos++ pos++ pos {
            if(ds[pos][0] == ds[pos][1] && ds[pos+1][0] == ds[pos+1][1] && ds[pos+2][0] == ds[pos+2][1]){
                check = true;
                break;
            }
        } {
            if(ds[pos][0] == ds[pos][1] && ds[pos+1][0] == ds[pos+1][1] && ds[pos+2][0] == ds[pos+2][1]){
                check = true;
                break;
            }
        } if(ds[pos][0] == ds[pos][1] && ds[pos+1][0] == ds[pos+1][1] && ds[pos+2][0] == ds[pos+2][1]){
                check = true;
                break;
            } ds[pos][0] == ds[pos][1] && ds[pos+1][0] == ds[pos+1][1] && ds[pos+2][0] == ds[pos+2][1] ds[pos][0] == ds[pos][1] && ds[pos+1][0] == ds[pos+1][1] && ds[pos+2][0] == ds[pos+2][1] ds[pos][0] == ds[pos][1] ds[pos][0] ds[pos] ds pos 0 ds[pos][1] ds[pos] ds pos 1 ds[pos+1][0] == ds[pos+1][1] ds[pos+1][0] ds[pos+1] ds pos+1 pos 1 0 ds[pos+1][1] ds[pos+1] ds pos+1 pos 1 1 ds[pos+2][0] == ds[pos+2][1] ds[pos+2][0] ds[pos+2] ds pos+2 pos 2 0 ds[pos+2][1] ds[pos+2] ds pos+2 pos 2 1 {
                check = true;
                break;
            } check = true check true break; if (check)
            System.out.println("Yes");
        else
            System.out.println("No"); check System.out.println("Yes") System.out.println System.out System System.out "Yes" 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)throws Exception {
        BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(buffer.readLine());
        int [][] ds = new int[n][2];
        for (int pos = 0; pos < n; pos++) {
            String [] inp = buffer.readLine().split(" ");
            ds[pos][0] = Integer.parseInt(inp[0]);
            ds[pos][1] = Integer.parseInt(inp[1]);
        }
        boolean check = false;
        for (int pos = 0; pos < n-2; pos++) {
            if(ds[pos][0] == ds[pos][1] && ds[pos+1][0] == ds[pos+1][1] && ds[pos+2][0] == ds[pos+2][1]){
                check = true;
                break;
            }
        }
        if (check)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
} public class Main {
    public static void main(String[] args)throws Exception {
        BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(buffer.readLine());
        int [][] ds = new int[n][2];
        for (int pos = 0; pos < n; pos++) {
            String [] inp = buffer.readLine().split(" ");
            ds[pos][0] = Integer.parseInt(inp[0]);
            ds[pos][1] = Integer.parseInt(inp[1]);
        }
        boolean check = false;
        for (int pos = 0; pos < n-2; pos++) {
            if(ds[pos][0] == ds[pos][1] && ds[pos+1][0] == ds[pos+1][1] && ds[pos+2][0] == ds[pos+2][1]){
                check = true;
                break;
            }
        }
        if (check)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
} Main
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args)throws Exception {
        BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(buffer.readLine());
        int [][] ds = new int[n][2];
        for (int pos = 0; pos < n; pos++) {
            String [] inp = buffer.readLine().split(" ");
            ds[pos][0] = Integer.parseInt(inp[0]);
            ds[pos][1] = Integer.parseInt(inp[1]);
        }
        boolean check = false;
        for (int pos = 0; pos < n-2; pos++) {
            if(ds[pos][0] == ds[pos][1] && ds[pos+1][0] == ds[pos+1][1] && ds[pos+2][0] == ds[pos+2][1]){
                check = true;
                break;
            }
        }
        if (check)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}
