#include <stdio.h>

int main(int argc, const char * argv[]) {
    int s1[6];
    int s2[6];
    int s3[6];
    int i,tmp,count = 0,check=0;
    for(i=0;i<6;i++){
        scanf("%d",&s1[i]);
    }
    for(i=0;i<6;i++){
        scanf("%d",&s2[i]);
        s3[i]=s2[i];
    }
    while(1){
        if(s1[0]==s2[0]){
            while(1){
                if(s1[0]==s2[0]&&s1[1]==s2[1]&&s1[2]==s2[2]&&s1[3]==s2[3]&&s1[4]==s2[4]&&s1[5]==s2[5]){
                    printf("Yes\n");
                    check=1;
                    break;
                }if(count==4){
                    count=0;
                    for(i=0;i<6;i++){
                        s2[i]=s3[i];
                    }
                    break;
                }else{//right spin
                    tmp=s2[3];
                    s2[3]=s2[4];
                    s2[4]=s2[2];
                    s2[2]=s2[1];
                    s2[1]=tmp;
                    count++;
                }
            }
        }if(s1[0]==s2[1]){
            tmp=s2[0];//North
            s2[0]=s2[1];
            s2[1]=s2[5];
            s2[5]=s2[4];
            s2[4]=tmp;
            while(1){
                if(s1[0]&&s2[0]&&s1[1]==s2[1]&&s1[2]==s2[2]&&s1[3]==s2[3]&&s1[4]==s2[4]&&s1[5]==s2[5]){
                    printf("Yes\n");
                    check=1;
                    break;
                }if(count==4){
                    count=0;
                    for(i=0;i<6;i++){
                        s2[i]=s3[i];
                    }
                    break;
                }else{//right
                    tmp=s2[3];
                    s2[3]=s2[4];
                    s2[4]=s2[2];
                    s2[2]=s2[1];
                    s2[1]=tmp;
                    count++;
                }
            }
        }if(s1[0]==s2[2]){
            tmp=s2[0];//West
            s2[0]=s2[2];
            s2[2]=s2[5];
            s2[5]=s2[3];
            s2[3]=tmp;
            while(1){
                if(s1[0]&&s2[0]&&s1[1]==s2[1]&&s1[2]==s2[2]&&s1[3]==s2[3]&&s1[4]==s2[4]&&s1[5]==s2[5]){
                    printf("Yes\n");
                    check=1;
                    break;
                }if(count==4){
                    count=0;
                    for(i=0;i<6;i++){
                        s2[i]=s3[i];
                    }
                    break;
                }else{//right
                    tmp=s2[3];
                    s2[3]=s2[4];
                    s2[4]=s2[2];
                    s2[2]=s2[1];
                    s2[1]=tmp;
                    count++;
                }
            }
        }if(s1[0]==s2[3]){
            tmp=s2[0];//East
            s2[0]=s2[3];
            s2[3]=s2[5];
            s2[5]=s2[2];
            s2[2]=tmp;
            while(1){
                if(s1[0]&&s2[0]&&s1[1]==s2[1]&&s1[2]==s2[2]&&s1[3]==s2[3]&&s1[4]==s2[4]&&s1[5]==s2[5]){
                    printf("Yes\n");
                    check=1;
                    break;
                }if(count==4){
                    count=0;
                    for(i=0;i<6;i++){
                        s2[i]=s3[i];
                    }
                    break;
                }else{//right
                    tmp=s2[3];
                    s2[3]=s2[4];
                    s2[4]=s2[2];
                    s2[2]=s2[1];
                    s2[1]=tmp;
                    count++;
                }
            }

        }if(s1[0]==s2[4]){
            tmp=s2[0];//South
            s2[0]=s2[4];
            s2[4]=s2[5];
            s2[5]=s2[1];
            s2[1]=tmp;
            while(1){
                if(s1[0]&&s2[0]&&s1[1]==s2[1]&&s1[2]==s2[2]&&s1[3]==s2[3]&&s1[4]==s2[4]&&s1[5]==s2[5]){
                    printf("Yes\n");
                    check=1;
                    break;
                }if(count==4){
                    count=0;
                    for(i=0;i<6;i++){
                        s2[i]=s3[i];
                    }
                    break;
                }else{//right
                    tmp=s2[3];
                    s2[3]=s2[4];
                    s2[4]=s2[2];
                    s2[2]=s2[1];
                    s2[1]=tmp;
                    count++;
                }
            }

        }if(s1[0]==s2[5]){
            tmp=s2[0];//South
            s2[0]=s2[4];
            s2[4]=s2[5];
            s2[5]=s2[1];
            s2[1]=tmp;
            tmp=s2[0];//South
            s2[0]=s2[4];
            s2[4]=s2[5];
            s2[5]=s2[1];
            s2[1]=tmp;
            while(1){
                if(s1[0]&&s2[0]&&s1[1]==s2[1]&&s1[2]==s2[2]&&s1[3]==s2[3]&&s1[4]==s2[4]&&s1[5]==s2[5]){
                    printf("Yes\n");
                    check=1;
                    break;
                }if(count==4){
                    count=0;
                    for(i=0;i<6;i++){
                        s2[i]=s3[i];
                    }
                    break;
                }else{//right
                    tmp=s2[3];
                    s2[3]=s2[4];
                    s2[4]=s2[2];
                    s2[2]=s2[1];
                    s2[1]=tmp;
                    count++;
                }
            }
            
        }if(check==1){
            break;
        }else{
            printf("No\n");
            break;

        }
    }
    return 0;
}




Measured memory_bytes: 2104