
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int a = sc.nextInt();
        int count = 0;
        String d;
        Boolean e = false;
        for (int i = 0; i < a; i++) {
            // スペース区切りの整数の入力
            int b = sc.nextInt();
            int c = sc.nextInt();

            if (b == c) {
                count += 1;
            } else {
                count = 0;
            }
            if (count == 3) {
                e = true;
            }
        }

        if (e) {
            d = "Yes";
        } else {
            d = "No";
        }

        // 出力
        System.out.println(d);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int a = sc.nextInt();
        int count = 0;
        String d;
        Boolean e = false;
        for (int i = 0; i < a; i++) {
            // スペース区切りの整数の入力
            int b = sc.nextInt();
            int c = sc.nextInt();

            if (b == c) {
                count += 1;
            } else {
                count = 0;
            }
            if (count == 3) {
                e = true;
            }
        }

        if (e) {
            d = "Yes";
        } else {
            d = "No";
        }

        // 出力
        System.out.println(d);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int a = sc.nextInt();
        int count = 0;
        String d;
        Boolean e = false;
        for (int i = 0; i < a; i++) {
            // スペース区切りの整数の入力
            int b = sc.nextInt();
            int c = sc.nextInt();

            if (b == c) {
                count += 1;
            } else {
                count = 0;
            }
            if (count == 3) {
                e = true;
            }
        }

        if (e) {
            d = "Yes";
        } else {
            d = "No";
        }

        // 出力
        System.out.println(d);
    } main {
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int a = sc.nextInt();
        int count = 0;
        String d;
        Boolean e = false;
        for (int i = 0; i < a; i++) {
            // スペース区切りの整数の入力
            int b = sc.nextInt();
            int c = sc.nextInt();

            if (b == c) {
                count += 1;
            } else {
                count = 0;
            }
            if (count == 3) {
                e = true;
            }
        }

        if (e) {
            d = "Yes";
        } else {
            d = "No";
        }

        // 出力
        System.out.println(d);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int a = sc.nextInt(); a sc.nextInt() sc.nextInt sc int count = 0; count 0 String d; d Boolean e = false; e false for (int i = 0; i < a; i++) {
            // スペース区切りの整数の入力
            int b = sc.nextInt();
            int c = sc.nextInt();

            if (b == c) {
                count += 1;
            } else {
                count = 0;
            }
            if (count == 3) {
                e = true;
            }
        } int i = 0; int i = 0; i 0 i < a i a i++ i++ i {
            // スペース区切りの整数の入力
            int b = sc.nextInt();
            int c = sc.nextInt();

            if (b == c) {
                count += 1;
            } else {
                count = 0;
            }
            if (count == 3) {
                e = true;
            }
        } {
            // スペース区切りの整数の入力
            int b = sc.nextInt();
            int c = sc.nextInt();

            if (b == c) {
                count += 1;
            } else {
                count = 0;
            }
            if (count == 3) {
                e = true;
            }
        } int b = sc.nextInt(); b sc.nextInt() sc.nextInt sc int c = sc.nextInt(); c sc.nextInt() sc.nextInt sc if (b == c) {
                count += 1;
            } else {
                count = 0;
            } b == c b c {
                count += 1;
            } count += 1 count 1 {
                count = 0;
            } count = 0 count 0 if (count == 3) {
                e = true;
            } count == 3 count 3 {
                e = true;
            } e = true e true if (e) {
            d = "Yes";
        } else {
            d = "No";
        } e {
            d = "Yes";
        } d = "Yes" d "Yes" {
            d = "No";
        } d = "No" d "No" System.out.println(d) System.out.println System.out System System.out d String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int a = sc.nextInt();
        int count = 0;
        String d;
        Boolean e = false;
        for (int i = 0; i < a; i++) {
            // スペース区切りの整数の入力
            int b = sc.nextInt();
            int c = sc.nextInt();

            if (b == c) {
                count += 1;
            } else {
                count = 0;
            }
            if (count == 3) {
                e = true;
            }
        }

        if (e) {
            d = "Yes";
        } else {
            d = "No";
        }

        // 出力
        System.out.println(d);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int a = sc.nextInt();
        int count = 0;
        String d;
        Boolean e = false;
        for (int i = 0; i < a; i++) {
            // スペース区切りの整数の入力
            int b = sc.nextInt();
            int c = sc.nextInt();

            if (b == c) {
                count += 1;
            } else {
                count = 0;
            }
            if (count == 3) {
                e = true;
            }
        }

        if (e) {
            d = "Yes";
        } else {
            d = "No";
        }

        // 出力
        System.out.println(d);
    }
} Main

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int a = sc.nextInt();
        int count = 0;
        String d;
        Boolean e = false;
        for (int i = 0; i < a; i++) {
            // スペース区切りの整数の入力
            int b = sc.nextInt();
            int c = sc.nextInt();

            if (b == c) {
                count += 1;
            } else {
                count = 0;
            }
            if (count == 3) {
                e = true;
            }
        }

        if (e) {
            d = "Yes";
        } else {
            d = "No";
        }

        // 出力
        System.out.println(d);
    }
}