import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.StringTokenizer;

class Main {
    private static InputReader in;
    private static PrintWriter out;

    // static String convert(String input){
    //     int lgt = input.length();
    //     char last = input.charAt(lgt-1);
    //     if(last == 's'){
    //         return input + "es";
    //     }else{
    //         return input + "s";
    //     }
            
    // }

    static String isInRow(List<Integer> lst){
        int lgt = lst.size();
        int temp3 = 0;
        for(int i =0; i < lgt-2; i++){
            temp3 = lst.get(i);
            if((temp3 != 0) && (lst.get(i+1) != 0) && (lst.get(i+2) != 0) )
                return "Yes";
        }
        return "No";
    }

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        in = new InputReader(inputStream);
        OutputStream outputStream = System.out;
        out = new PrintWriter(outputStream);

        int length = in.nextInt();
        List<Integer> arr = new ArrayList<Integer>();
        List<Integer> arr2 = new ArrayList<Integer>();
        int counter = 0;
        int temp = 0;
        while(counter < length * 2){
            temp = in.nextInt();
            arr.add(temp);
            counter++;
        }
        // System.out.println(arr);

        int temp2 = 0;
        for(int i = 0; i < length; i++){
            temp2 = arr.get(i*2);
            if(temp2 == arr.get(i*2+1)){
                arr2.add(temp2);
            }
            else{
                arr2.add(0);
            }
        }
        System.out.println(isInRow(arr2));
            
        }

    // taken from https://codeforces.com/submissions/Petr
    // together with PrintWriter, these input-output (IO) is much faster than the usual Scanner(System.in) and System.out
    // please use these classes to avoid your fast algorithm gets Time Limit Exceeded caused by slow input-output (IO)
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;
 
        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }
 
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
 
        public int nextInt() {
            return Integer.parseInt(next());
        }
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStream; InputStream java.io import java.io.InputStreamReader; InputStreamReader java.io import java.io.OutputStream; OutputStream java.io import java.io.PrintWriter; PrintWriter java.io import java.util.ArrayList; ArrayList java.util import java.util.Collections; Collections java.util import java.util.List; List java.util import java.util.StringTokenizer; StringTokenizer java.util class Main {
    private static InputReader in;
    private static PrintWriter out;

    // static String convert(String input){
    //     int lgt = input.length();
    //     char last = input.charAt(lgt-1);
    //     if(last == 's'){
    //         return input + "es";
    //     }else{
    //         return input + "s";
    //     }
            
    // }

    static String isInRow(List<Integer> lst){
        int lgt = lst.size();
        int temp3 = 0;
        for(int i =0; i < lgt-2; i++){
            temp3 = lst.get(i);
            if((temp3 != 0) && (lst.get(i+1) != 0) && (lst.get(i+2) != 0) )
                return "Yes";
        }
        return "No";
    }

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        in = new InputReader(inputStream);
        OutputStream outputStream = System.out;
        out = new PrintWriter(outputStream);

        int length = in.nextInt();
        List<Integer> arr = new ArrayList<Integer>();
        List<Integer> arr2 = new ArrayList<Integer>();
        int counter = 0;
        int temp = 0;
        while(counter < length * 2){
            temp = in.nextInt();
            arr.add(temp);
            counter++;
        }
        // System.out.println(arr);

        int temp2 = 0;
        for(int i = 0; i < length; i++){
            temp2 = arr.get(i*2);
            if(temp2 == arr.get(i*2+1)){
                arr2.add(temp2);
            }
            else{
                arr2.add(0);
            }
        }
        System.out.println(isInRow(arr2));
            
        }

    // taken from https://codeforces.com/submissions/Petr
    // together with PrintWriter, these input-output (IO) is much faster than the usual Scanner(System.in) and System.out
    // please use these classes to avoid your fast algorithm gets Time Limit Exceeded caused by slow input-output (IO)
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;
 
        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }
 
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
 
        public int nextInt() {
            return Integer.parseInt(next());
        }
    }
} Main private static InputReader in; in private static PrintWriter out; out static String isInRow(List<Integer> lst){
        int lgt = lst.size();
        int temp3 = 0;
        for(int i =0; i < lgt-2; i++){
            temp3 = lst.get(i);
            if((temp3 != 0) && (lst.get(i+1) != 0) && (lst.get(i+2) != 0) )
                return "Yes";
        }
        return "No";
    } isInRow {
        int lgt = lst.size();
        int temp3 = 0;
        for(int i =0; i < lgt-2; i++){
            temp3 = lst.get(i);
            if((temp3 != 0) && (lst.get(i+1) != 0) && (lst.get(i+2) != 0) )
                return "Yes";
        }
        return "No";
    } int lgt = lst.size(); lgt lst.size() lst.size lst int temp3 = 0; temp3 0 for(int i =0; i < lgt-2; i++){
            temp3 = lst.get(i);
            if((temp3 != 0) && (lst.get(i+1) != 0) && (lst.get(i+2) != 0) )
                return "Yes";
        } int i =0; int i =0; i 0 i < lgt-2 i lgt-2 lgt 2 i++ i++ i {
            temp3 = lst.get(i);
            if((temp3 != 0) && (lst.get(i+1) != 0) && (lst.get(i+2) != 0) )
                return "Yes";
        } {
            temp3 = lst.get(i);
            if((temp3 != 0) && (lst.get(i+1) != 0) && (lst.get(i+2) != 0) )
                return "Yes";
        } temp3 = lst.get(i) temp3 lst.get(i) lst.get lst i if((temp3 != 0) && (lst.get(i+1) != 0) && (lst.get(i+2) != 0) )
                return "Yes"; (temp3 != 0) && (lst.get(i+1) != 0) && (lst.get(i+2) != 0) (temp3 != 0) && (lst.get(i+1) != 0) && (lst.get(i+2) != 0) (temp3 != 0) temp3 0 (lst.get(i+1) != 0) lst.get(i+1) lst.get lst i+1 i 1 0 (lst.get(i+2) != 0) lst.get(i+2) lst.get lst i+2 i 2 0 return "Yes"; "Yes" return "No"; "No" List<Integer> lst lst public static void main(String[] args) {
        InputStream inputStream = System.in;
        in = new InputReader(inputStream);
        OutputStream outputStream = System.out;
        out = new PrintWriter(outputStream);

        int length = in.nextInt();
        List<Integer> arr = new ArrayList<Integer>();
        List<Integer> arr2 = new ArrayList<Integer>();
        int counter = 0;
        int temp = 0;
        while(counter < length * 2){
            temp = in.nextInt();
            arr.add(temp);
            counter++;
        }
        // System.out.println(arr);

        int temp2 = 0;
        for(int i = 0; i < length; i++){
            temp2 = arr.get(i*2);
            if(temp2 == arr.get(i*2+1)){
                arr2.add(temp2);
            }
            else{
                arr2.add(0);
            }
        }
        System.out.println(isInRow(arr2));
            
        } main {
        InputStream inputStream = System.in;
        in = new InputReader(inputStream);
        OutputStream outputStream = System.out;
        out = new PrintWriter(outputStream);

        int length = in.nextInt();
        List<Integer> arr = new ArrayList<Integer>();
        List<Integer> arr2 = new ArrayList<Integer>();
        int counter = 0;
        int temp = 0;
        while(counter < length * 2){
            temp = in.nextInt();
            arr.add(temp);
            counter++;
        }
        // System.out.println(arr);

        int temp2 = 0;
        for(int i = 0; i < length; i++){
            temp2 = arr.get(i*2);
            if(temp2 == arr.get(i*2+1)){
                arr2.add(temp2);
            }
            else{
                arr2.add(0);
            }
        }
        System.out.println(isInRow(arr2));
            
        } InputStream inputStream = System.in; inputStream System.in System System.in in = new InputReader(inputStream) in new InputReader(inputStream) OutputStream outputStream = System.out; outputStream System.out System System.out out = new PrintWriter(outputStream) out new PrintWriter(outputStream) int length = in.nextInt(); length in.nextInt() in.nextInt in List<Integer> arr = new ArrayList<Integer>(); arr new ArrayList<Integer>() List<Integer> arr2 = new ArrayList<Integer>(); arr2 new ArrayList<Integer>() int counter = 0; counter 0 int temp = 0; temp 0 while(counter < length * 2){
            temp = in.nextInt();
            arr.add(temp);
            counter++;
        } counter < length * 2 counter length * 2 length 2 {
            temp = in.nextInt();
            arr.add(temp);
            counter++;
        } temp = in.nextInt() temp in.nextInt() in.nextInt in arr.add(temp) arr.add arr temp counter++ counter int temp2 = 0; temp2 0 for(int i = 0; i < length; i++){
            temp2 = arr.get(i*2);
            if(temp2 == arr.get(i*2+1)){
                arr2.add(temp2);
            }
            else{
                arr2.add(0);
            }
        } int i = 0; int i = 0; i 0 i < length i length i++ i++ i {
            temp2 = arr.get(i*2);
            if(temp2 == arr.get(i*2+1)){
                arr2.add(temp2);
            }
            else{
                arr2.add(0);
            }
        } {
            temp2 = arr.get(i*2);
            if(temp2 == arr.get(i*2+1)){
                arr2.add(temp2);
            }
            else{
                arr2.add(0);
            }
        } temp2 = arr.get(i*2) temp2 arr.get(i*2) arr.get arr i*2 i 2 if(temp2 == arr.get(i*2+1)){
                arr2.add(temp2);
            }
            else{
                arr2.add(0);
            } temp2 == arr.get(i*2+1) temp2 arr.get(i*2+1) arr.get arr i*2+1 i*2 i 2 1 {
                arr2.add(temp2);
            } arr2.add(temp2) arr2.add arr2 temp2 {
                arr2.add(0);
            } arr2.add(0) arr2.add arr2 0 System.out.println(isInRow(arr2)) System.out.println System.out System System.out isInRow(arr2) isInRow arr2 String[] args args static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;
 
        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }
 
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
 
        public int nextInt() {
            return Integer.parseInt(next());
        }
    } InputReader public BufferedReader reader; reader public StringTokenizer tokenizer; tokenizer public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        } InputReader {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        } reader = new BufferedReader(new InputStreamReader(stream), 32768) reader new BufferedReader(new InputStreamReader(stream), 32768) tokenizer = null tokenizer null InputStream stream stream public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        } next {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        } while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            } tokenizer == null || !tokenizer.hasMoreTokens() tokenizer == null tokenizer null !tokenizer.hasMoreTokens() tokenizer.hasMoreTokens() tokenizer.hasMoreTokens tokenizer {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            } try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                } IOException e {
                    throw new RuntimeException(e);
                } throw new RuntimeException(e); new RuntimeException(e) {
                    tokenizer = new StringTokenizer(reader.readLine());
                } tokenizer = new StringTokenizer(reader.readLine()) tokenizer new StringTokenizer(reader.readLine()) return tokenizer.nextToken(); tokenizer.nextToken() tokenizer.nextToken tokenizer public int nextInt() {
            return Integer.parseInt(next());
        } nextInt {
            return Integer.parseInt(next());
        } return Integer.parseInt(next()); Integer.parseInt(next()) Integer.parseInt Integer next() next
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.StringTokenizer;

class Main {
    private static InputReader in;
    private static PrintWriter out;

    // static String convert(String input){
    //     int lgt = input.length();
    //     char last = input.charAt(lgt-1);
    //     if(last == 's'){
    //         return input + "es";
    //     }else{
    //         return input + "s";
    //     }
            
    // }

    static String isInRow(List<Integer> lst){
        int lgt = lst.size();
        int temp3 = 0;
        for(int i =0; i < lgt-2; i++){
            temp3 = lst.get(i);
            if((temp3 != 0) && (lst.get(i+1) != 0) && (lst.get(i+2) != 0) )
                return "Yes";
        }
        return "No";
    }

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        in = new InputReader(inputStream);
        OutputStream outputStream = System.out;
        out = new PrintWriter(outputStream);

        int length = in.nextInt();
        List<Integer> arr = new ArrayList<Integer>();
        List<Integer> arr2 = new ArrayList<Integer>();
        int counter = 0;
        int temp = 0;
        while(counter < length * 2){
            temp = in.nextInt();
            arr.add(temp);
            counter++;
        }
        // System.out.println(arr);

        int temp2 = 0;
        for(int i = 0; i < length; i++){
            temp2 = arr.get(i*2);
            if(temp2 == arr.get(i*2+1)){
                arr2.add(temp2);
            }
            else{
                arr2.add(0);
            }
        }
        System.out.println(isInRow(arr2));
            
        }

    // taken from https://codeforces.com/submissions/Petr
    // together with PrintWriter, these input-output (IO) is much faster than the usual Scanner(System.in) and System.out
    // please use these classes to avoid your fast algorithm gets Time Limit Exceeded caused by slow input-output (IO)
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;
 
        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }
 
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
 
        public int nextInt() {
            return Integer.parseInt(next());
        }
    }
}