//package src.com.jetman.atcoder;

import java.util.*;

/**
 * @description:
 * @author: Jetman
 * @create: 2020-08-29 14:39
 **/
public class Main {

    Scanner sc = new Scanner(System.in);

    long MOD = 1000000000 + 7;

    long dp[][];

    private void slove() {

        int n = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
        }

        boolean ans = false;
        for (int i = 2; i < n; i++) {
            if (a[i] != b[i]) continue;
            if (a[i-1] == b[i-1] && a[i-2] == b[i-2]) {
                ans = true;
                break;
            }
        }

        System.out.println(ans?"Yes":"No");



    }

    private void build(Map<Integer, List<Integer>> edge, int l, int r) {
        List<Integer> list = edge.getOrDefault(l, new ArrayList<>());
        list.add(r);
        edge.put(l,list);
    }


    public static void main(String[] args) {
        new Main().slove();
    }
} import java.util.*; util.* java public class Main {

    Scanner sc = new Scanner(System.in);

    long MOD = 1000000000 + 7;

    long dp[][];

    private void slove() {

        int n = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
        }

        boolean ans = false;
        for (int i = 2; i < n; i++) {
            if (a[i] != b[i]) continue;
            if (a[i-1] == b[i-1] && a[i-2] == b[i-2]) {
                ans = true;
                break;
            }
        }

        System.out.println(ans?"Yes":"No");



    }

    private void build(Map<Integer, List<Integer>> edge, int l, int r) {
        List<Integer> list = edge.getOrDefault(l, new ArrayList<>());
        list.add(r);
        edge.put(l,list);
    }


    public static void main(String[] args) {
        new Main().slove();
    }
} Main Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long MOD = 1000000000 + 7; MOD 1000000000 + 7 1000000000 7 long dp[][]; dp private void slove() {

        int n = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
        }

        boolean ans = false;
        for (int i = 2; i < n; i++) {
            if (a[i] != b[i]) continue;
            if (a[i-1] == b[i-1] && a[i-2] == b[i-2]) {
                ans = true;
                break;
            }
        }

        System.out.println(ans?"Yes":"No");



    } slove {

        int n = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
        }

        boolean ans = false;
        for (int i = 2; i < n; i++) {
            if (a[i] != b[i]) continue;
            if (a[i-1] == b[i-1] && a[i-2] == b[i-2]) {
                ans = true;
                break;
            }
        }

        System.out.println(ans?"Yes":"No");



    } int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int[] a = new int[n]; a new int[n] n int[] b = new int[n]; b new int[n] n for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
        } {
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
        } a[i] = sc.nextInt() a[i] a i sc.nextInt() sc.nextInt sc b[i] = sc.nextInt() b[i] b i sc.nextInt() sc.nextInt sc boolean ans = false; ans false for (int i = 2; i < n; i++) {
            if (a[i] != b[i]) continue;
            if (a[i-1] == b[i-1] && a[i-2] == b[i-2]) {
                ans = true;
                break;
            }
        } int i = 2; int i = 2; i 2 i < n i n i++ i++ i {
            if (a[i] != b[i]) continue;
            if (a[i-1] == b[i-1] && a[i-2] == b[i-2]) {
                ans = true;
                break;
            }
        } {
            if (a[i] != b[i]) continue;
            if (a[i-1] == b[i-1] && a[i-2] == b[i-2]) {
                ans = true;
                break;
            }
        } if (a[i] != b[i]) continue; a[i] != b[i] a[i] a i b[i] b i continue; if (a[i-1] == b[i-1] && a[i-2] == b[i-2]) {
                ans = true;
                break;
            } a[i-1] == b[i-1] && a[i-2] == b[i-2] a[i-1] == b[i-1] a[i-1] a i-1 i 1 b[i-1] b i-1 i 1 a[i-2] == b[i-2] a[i-2] a i-2 i 2 b[i-2] b i-2 i 2 {
                ans = true;
                break;
            } ans = true ans true break; System.out.println(ans?"Yes":"No") System.out.println System.out System System.out ans?"Yes":"No" ans "Yes" "No" private void build(Map<Integer, List<Integer>> edge, int l, int r) {
        List<Integer> list = edge.getOrDefault(l, new ArrayList<>());
        list.add(r);
        edge.put(l,list);
    } build {
        List<Integer> list = edge.getOrDefault(l, new ArrayList<>());
        list.add(r);
        edge.put(l,list);
    } List<Integer> list = edge.getOrDefault(l, new ArrayList<>()); list edge.getOrDefault(l, new ArrayList<>()) edge.getOrDefault edge l new ArrayList<>() list.add(r) list.add list r edge.put(l,list) edge.put edge l list Map<Integer, List<Integer>> edge edge int l l int r r public static void main(String[] args) {
        new Main().slove();
    } main {
        new Main().slove();
    } new Main().slove() new Main().slove new Main() String[] args args public class Main {

    Scanner sc = new Scanner(System.in);

    long MOD = 1000000000 + 7;

    long dp[][];

    private void slove() {

        int n = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
        }

        boolean ans = false;
        for (int i = 2; i < n; i++) {
            if (a[i] != b[i]) continue;
            if (a[i-1] == b[i-1] && a[i-2] == b[i-2]) {
                ans = true;
                break;
            }
        }

        System.out.println(ans?"Yes":"No");



    }

    private void build(Map<Integer, List<Integer>> edge, int l, int r) {
        List<Integer> list = edge.getOrDefault(l, new ArrayList<>());
        list.add(r);
        edge.put(l,list);
    }


    public static void main(String[] args) {
        new Main().slove();
    }
} public class Main {

    Scanner sc = new Scanner(System.in);

    long MOD = 1000000000 + 7;

    long dp[][];

    private void slove() {

        int n = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
        }

        boolean ans = false;
        for (int i = 2; i < n; i++) {
            if (a[i] != b[i]) continue;
            if (a[i-1] == b[i-1] && a[i-2] == b[i-2]) {
                ans = true;
                break;
            }
        }

        System.out.println(ans?"Yes":"No");



    }

    private void build(Map<Integer, List<Integer>> edge, int l, int r) {
        List<Integer> list = edge.getOrDefault(l, new ArrayList<>());
        list.add(r);
        edge.put(l,list);
    }


    public static void main(String[] args) {
        new Main().slove();
    }
} Main
//package src.com.jetman.atcoder;

import java.util.*;

/**
 * @description:
 * @author: Jetman
 * @create: 2020-08-29 14:39
 **/
public class Main {

    Scanner sc = new Scanner(System.in);

    long MOD = 1000000000 + 7;

    long dp[][];

    private void slove() {

        int n = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
        }

        boolean ans = false;
        for (int i = 2; i < n; i++) {
            if (a[i] != b[i]) continue;
            if (a[i-1] == b[i-1] && a[i-2] == b[i-2]) {
                ans = true;
                break;
            }
        }

        System.out.println(ans?"Yes":"No");



    }

    private void build(Map<Integer, List<Integer>> edge, int l, int r) {
        List<Integer> list = edge.getOrDefault(l, new ArrayList<>());
        list.add(r);
        edge.put(l,list);
    }


    public static void main(String[] args) {
        new Main().slove();
    }
}
