#include <stdio.h>
#include <cstring>

void east_change(int dice[]){
	int copy_dice[6];
	memcpy(copy_dice, dice, 6*sizeof(*dice));
	for(int i = 0; i < 6; i++){
		if(i + 1 == 1){
			dice[i] = copy_dice[3];
		}else if(i + 1 == 3){
			dice[i] = copy_dice[0];
		}else if(i + 1 == 4){
			dice[i] = copy_dice[5];
		}else if(i + 1 == 6){
			dice[i] = copy_dice[2];
		}
	}
}

void south_change(int dice[]){
	int copy_dice[6];
	memcpy(copy_dice, dice, 6*sizeof(*dice));
	for(int i = 0; i < 6; i++){
		if(i + 1 == 1){
			dice[i] = copy_dice[4];
		}else if(i + 1 == 2){
			dice[i] = copy_dice[0];
		}else if(i + 1 == 5){
			dice[i] = copy_dice[5];
		}else if(i + 1 == 6){
			dice[i] = copy_dice[1];
		}
	}
}

void north_change(int dice[]){
	int copy_dice[6];
	memcpy(copy_dice, dice, 6*sizeof(*dice));
	for(int i = 0; i < 6; i++){
		if(i + 1 == 1){
			dice[i] = copy_dice[1];
		}else if(i + 1 == 2){
			dice[i] = copy_dice[5];
		}else if(i + 1 == 5){
			dice[i] = copy_dice[0];
		}else if(i + 1 == 6){
			dice[i] = copy_dice[4];
		}
	}
}

bool match_dice(int dice1[], int dice2[]){
    for(int i = 0; i < 6; i++){
        if(dice1[i] != dice2[i]){
            return false;
        }
    }
    return true;
}

bool rotate_ismatch(int dice1[], int dice2[], char pattern[]){
    int i = 0;
    int copy_dice2[6];
	memcpy(copy_dice2, dice2, 6*sizeof(*dice2));
    while(true){
		if(std::strncmp(&pattern[i], "E", 1) == 0 ){
			east_change(dice2);
            if (match_dice(dice1, dice2)){
               memcpy(dice2, copy_dice2, 6*sizeof(*dice2)); 
               return true;
            }
		}else if(std::strncmp(&pattern[i], "S", 1) == 0 ){
			south_change(dice2);
            if (match_dice(dice1, dice2)){
               memcpy(dice2, copy_dice2, 6*sizeof(*dice2)); 
               return true;
            }
		}else if(std::strncmp(&pattern[i], "N", 1) == 0 ){
			north_change(dice2);
            if (match_dice(dice1, dice2)){
               memcpy(dice2, copy_dice2, 6*sizeof(*dice2)); 
               return true;
            }
		}else{
			break;
		}
		i++;
	}
    memcpy(dice2, copy_dice2, 6*sizeof(*dice2)); 
    return false;
}

int main(){
    int dice1[6];
    int dice2[6];
    for(int i = 0; i < 6; i++) scanf("%d",&dice1[i]);
    for(int i = 0; i < 6; i++) scanf("%d",&dice2[i]);
    
    char pattern1[] = "EEEE";
    char pattern2[] = "SEEE";
    char pattern3[] = "SSEEE";
    char pattern4[] = "SSSEEE";
    char pattern5[] = "ESEEE";
    char pattern6[] = "ENEEE";

    while(true){
        if(rotate_ismatch(dice1, dice2, pattern1)){
            printf("Yes\n");
            break;
        }else if(rotate_ismatch(dice1, dice2, pattern2)){
            printf("Yes\n");
            break;
        }else if(rotate_ismatch(dice1, dice2, pattern3)){
            printf("Yes\n");
            break;
        }else if(rotate_ismatch(dice1, dice2, pattern4)){
            printf("Yes\n");
            break;
        }else if(rotate_ismatch(dice1, dice2, pattern5)){
            printf("Yes\n");
            break;
        }else if(rotate_ismatch(dice1, dice2, pattern6)){
            printf("Yes\n");
            break;
        }
        printf("No\n");
        break;
    }

}

/*
1 2 3 4 5 6
6 2 4 3 5 1
Sample Output
Yes

Sample Input
1 2 3 4 5 6
6 5 4 3 2 1
Sample Output
No

*/


Measured memory_bytes: 2624