import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a, b;
        int me[][] = new int [3][2];
        int flg = 0;
        for(int i = 0; i < n; i++){
            a = sc.nextInt();
            b = sc.nextInt();
            me[i % 3][0] = a;
            me[i % 3][1] = b;
            if(i > 1){
                if(me[0][0] == me[0][1] && me[1][0] == me[1][1] && me[2][0] == me[2][1]){
                    System.out.println("Yes");
                    flg += 1;
                    break;
                }
            }
        }
        if(flg == 0){
            System.out.println("No");
        }
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a, b;
        int me[][] = new int [3][2];
        int flg = 0;
        for(int i = 0; i < n; i++){
            a = sc.nextInt();
            b = sc.nextInt();
            me[i % 3][0] = a;
            me[i % 3][1] = b;
            if(i > 1){
                if(me[0][0] == me[0][1] && me[1][0] == me[1][1] && me[2][0] == me[2][1]){
                    System.out.println("Yes");
                    flg += 1;
                    break;
                }
            }
        }
        if(flg == 0){
            System.out.println("No");
        }
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a, b;
        int me[][] = new int [3][2];
        int flg = 0;
        for(int i = 0; i < n; i++){
            a = sc.nextInt();
            b = sc.nextInt();
            me[i % 3][0] = a;
            me[i % 3][1] = b;
            if(i > 1){
                if(me[0][0] == me[0][1] && me[1][0] == me[1][1] && me[2][0] == me[2][1]){
                    System.out.println("Yes");
                    flg += 1;
                    break;
                }
            }
        }
        if(flg == 0){
            System.out.println("No");
        }
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a, b;
        int me[][] = new int [3][2];
        int flg = 0;
        for(int i = 0; i < n; i++){
            a = sc.nextInt();
            b = sc.nextInt();
            me[i % 3][0] = a;
            me[i % 3][1] = b;
            if(i > 1){
                if(me[0][0] == me[0][1] && me[1][0] == me[1][1] && me[2][0] == me[2][1]){
                    System.out.println("Yes");
                    flg += 1;
                    break;
                }
            }
        }
        if(flg == 0){
            System.out.println("No");
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int a a b; b int me[][] = new int [3][2]; me new int [3][2] 3 2 int flg = 0; flg 0 for(int i = 0; i < n; i++){
            a = sc.nextInt();
            b = sc.nextInt();
            me[i % 3][0] = a;
            me[i % 3][1] = b;
            if(i > 1){
                if(me[0][0] == me[0][1] && me[1][0] == me[1][1] && me[2][0] == me[2][1]){
                    System.out.println("Yes");
                    flg += 1;
                    break;
                }
            }
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            a = sc.nextInt();
            b = sc.nextInt();
            me[i % 3][0] = a;
            me[i % 3][1] = b;
            if(i > 1){
                if(me[0][0] == me[0][1] && me[1][0] == me[1][1] && me[2][0] == me[2][1]){
                    System.out.println("Yes");
                    flg += 1;
                    break;
                }
            }
        } {
            a = sc.nextInt();
            b = sc.nextInt();
            me[i % 3][0] = a;
            me[i % 3][1] = b;
            if(i > 1){
                if(me[0][0] == me[0][1] && me[1][0] == me[1][1] && me[2][0] == me[2][1]){
                    System.out.println("Yes");
                    flg += 1;
                    break;
                }
            }
        } a = sc.nextInt() a sc.nextInt() sc.nextInt sc b = sc.nextInt() b sc.nextInt() sc.nextInt sc me[i % 3][0] = a me[i % 3][0] me[i % 3] me i % 3 i 3 0 a me[i % 3][1] = b me[i % 3][1] me[i % 3] me i % 3 i 3 1 b if(i > 1){
                if(me[0][0] == me[0][1] && me[1][0] == me[1][1] && me[2][0] == me[2][1]){
                    System.out.println("Yes");
                    flg += 1;
                    break;
                }
            } i > 1 i 1 {
                if(me[0][0] == me[0][1] && me[1][0] == me[1][1] && me[2][0] == me[2][1]){
                    System.out.println("Yes");
                    flg += 1;
                    break;
                }
            } if(me[0][0] == me[0][1] && me[1][0] == me[1][1] && me[2][0] == me[2][1]){
                    System.out.println("Yes");
                    flg += 1;
                    break;
                } me[0][0] == me[0][1] && me[1][0] == me[1][1] && me[2][0] == me[2][1] me[0][0] == me[0][1] && me[1][0] == me[1][1] && me[2][0] == me[2][1] me[0][0] == me[0][1] me[0][0] me[0] me 0 0 me[0][1] me[0] me 0 1 me[1][0] == me[1][1] me[1][0] me[1] me 1 0 me[1][1] me[1] me 1 1 me[2][0] == me[2][1] me[2][0] me[2] me 2 0 me[2][1] me[2] me 2 1 {
                    System.out.println("Yes");
                    flg += 1;
                    break;
                } System.out.println("Yes") System.out.println System.out System System.out "Yes" flg += 1 flg 1 break; if(flg == 0){
            System.out.println("No");
        } flg == 0 flg 0 {
            System.out.println("No");
        } 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){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a, b;
        int me[][] = new int [3][2];
        int flg = 0;
        for(int i = 0; i < n; i++){
            a = sc.nextInt();
            b = sc.nextInt();
            me[i % 3][0] = a;
            me[i % 3][1] = b;
            if(i > 1){
                if(me[0][0] == me[0][1] && me[1][0] == me[1][1] && me[2][0] == me[2][1]){
                    System.out.println("Yes");
                    flg += 1;
                    break;
                }
            }
        }
        if(flg == 0){
            System.out.println("No");
        }
    }
} public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a, b;
        int me[][] = new int [3][2];
        int flg = 0;
        for(int i = 0; i < n; i++){
            a = sc.nextInt();
            b = sc.nextInt();
            me[i % 3][0] = a;
            me[i % 3][1] = b;
            if(i > 1){
                if(me[0][0] == me[0][1] && me[1][0] == me[1][1] && me[2][0] == me[2][1]){
                    System.out.println("Yes");
                    flg += 1;
                    break;
                }
            }
        }
        if(flg == 0){
            System.out.println("No");
        }
    }
} Main
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a, b;
        int me[][] = new int [3][2];
        int flg = 0;
        for(int i = 0; i < n; i++){
            a = sc.nextInt();
            b = sc.nextInt();
            me[i % 3][0] = a;
            me[i % 3][1] = b;
            if(i > 1){
                if(me[0][0] == me[0][1] && me[1][0] == me[1][1] && me[2][0] == me[2][1]){
                    System.out.println("Yes");
                    flg += 1;
                    break;
                }
            }
        }
        if(flg == 0){
            System.out.println("No");
        }
    }
}
