import java.util.Scanner;

public class Main {
    public static void main(String s[]){
        Scanner sc=new Scanner(System.in);
        int n=0;
        if(sc.hasNextInt())
            n=sc.nextInt();
        int cnt=0;
        boolean res=false;
        while(n--!=0){
            byte x=sc.nextByte();
            byte y=sc.nextByte();
            if(x==y)
                cnt++;
            else
                cnt=0;
            if(cnt==3)
                res=true;
        }
        if(res)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String s[]){
        Scanner sc=new Scanner(System.in);
        int n=0;
        if(sc.hasNextInt())
            n=sc.nextInt();
        int cnt=0;
        boolean res=false;
        while(n--!=0){
            byte x=sc.nextByte();
            byte y=sc.nextByte();
            if(x==y)
                cnt++;
            else
                cnt=0;
            if(cnt==3)
                res=true;
        }
        if(res)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
} Main public static void main(String s[]){
        Scanner sc=new Scanner(System.in);
        int n=0;
        if(sc.hasNextInt())
            n=sc.nextInt();
        int cnt=0;
        boolean res=false;
        while(n--!=0){
            byte x=sc.nextByte();
            byte y=sc.nextByte();
            if(x==y)
                cnt++;
            else
                cnt=0;
            if(cnt==3)
                res=true;
        }
        if(res)
            System.out.println("Yes");
        else
            System.out.println("No");
    } main {
        Scanner sc=new Scanner(System.in);
        int n=0;
        if(sc.hasNextInt())
            n=sc.nextInt();
        int cnt=0;
        boolean res=false;
        while(n--!=0){
            byte x=sc.nextByte();
            byte y=sc.nextByte();
            if(x==y)
                cnt++;
            else
                cnt=0;
            if(cnt==3)
                res=true;
        }
        if(res)
            System.out.println("Yes");
        else
            System.out.println("No");
    } Scanner sc=new Scanner(System.in); sc new Scanner(System.in) int n=0; n 0 if(sc.hasNextInt())
            n=sc.nextInt(); sc.hasNextInt() sc.hasNextInt sc n=sc.nextInt() n sc.nextInt() sc.nextInt sc int cnt=0; cnt 0 boolean res=false; res false while(n--!=0){
            byte x=sc.nextByte();
            byte y=sc.nextByte();
            if(x==y)
                cnt++;
            else
                cnt=0;
            if(cnt==3)
                res=true;
        } n--!=0 n-- n 0 {
            byte x=sc.nextByte();
            byte y=sc.nextByte();
            if(x==y)
                cnt++;
            else
                cnt=0;
            if(cnt==3)
                res=true;
        } byte x=sc.nextByte(); x sc.nextByte() sc.nextByte sc byte y=sc.nextByte(); y sc.nextByte() sc.nextByte sc if(x==y)
                cnt++;
            else
                cnt=0; x==y x y cnt++ cnt cnt=0 cnt 0 if(cnt==3)
                res=true; cnt==3 cnt 3 res=true res true if(res)
            System.out.println("Yes");
        else
            System.out.println("No"); res 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 s[] s public class Main {
    public static void main(String s[]){
        Scanner sc=new Scanner(System.in);
        int n=0;
        if(sc.hasNextInt())
            n=sc.nextInt();
        int cnt=0;
        boolean res=false;
        while(n--!=0){
            byte x=sc.nextByte();
            byte y=sc.nextByte();
            if(x==y)
                cnt++;
            else
                cnt=0;
            if(cnt==3)
                res=true;
        }
        if(res)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
} public class Main {
    public static void main(String s[]){
        Scanner sc=new Scanner(System.in);
        int n=0;
        if(sc.hasNextInt())
            n=sc.nextInt();
        int cnt=0;
        boolean res=false;
        while(n--!=0){
            byte x=sc.nextByte();
            byte y=sc.nextByte();
            if(x==y)
                cnt++;
            else
                cnt=0;
            if(cnt==3)
                res=true;
        }
        if(res)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String s[]){
        Scanner sc=new Scanner(System.in);
        int n=0;
        if(sc.hasNextInt())
            n=sc.nextInt();
        int cnt=0;
        boolean res=false;
        while(n--!=0){
            byte x=sc.nextByte();
            byte y=sc.nextByte();
            if(x==y)
                cnt++;
            else
                cnt=0;
            if(cnt==3)
                res=true;
        }
        if(res)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}
