/*
   AOJ - ITP11_1_c
Date: 20181024
Author: Mikoron * ♡mikoiwate351♡
*/

#include<stdio.h>
#include<string.h>

#define CMAX 101
#define TOP 1
#define FRONT 2
#define RIGHT 3
#define LEFT 4
#define BACK 5
#define BOTTOM 6


typedef struct {
        short suf[7];
} dice_state_t;

void show_state(dice_state_t *dice, short s_suf);
void change_state(dice_state_t *dice, char command);
short search_RIGHT(dice_state_t *dice, short s_TOP, short s_FRONT);
short compare_dice(dice_state_t *dice1, dice_state_t *dice2);
void replace_y(dice_state_t *dice);
void replace_x(dice_state_t *dice);
void replace_z(dice_state_t *dice);

int main(void) {

        short i;

        dice_state_t dice1, dice2;

        for(i = 1; i < 7; i++) scanf("%hd", &dice1.suf[i]);
        for(i = 1; i < 7; i++) scanf("%hd", &dice2.suf[i]);

        if(compare_dice(&dice1, &dice2)) printf("No\n");
        else printf("Yes\n");

        return 0;
}

void show_state(dice_state_t *dice, short s_suf) {
        printf("%hd\n", dice->suf[s_suf]);
}


void change_state(dice_state_t *dice, char command) {
        short i;

        switch(command) {
                case 'N':
                        replace_y(dice);
                        break;
                case 'E':
                        replace_x(dice);
                        break;
                case 'S':
                        for(i = 0; i < 3; i++) replace_y(dice);
                        break;
                case 'W':
                        for(i = 0; i < 3; i++) replace_x(dice);
                        break;
        }

}

short search_RIGHT(dice_state_t *dice, short s_TOP, short s_FRONT) {
        short flag_TOP = 0, flag_FRONT = 0, i, j;
        for(i = 0; i < 2; i++) {
                if(flag_TOP == 1) break;
                for(j = 0; j < 4; j++) {
                        if(dice->suf[TOP] == s_TOP) flag_TOP = 1;
                        if(flag_TOP == 1) break;
                        if(i == 0) replace_y(dice);
                        else if(i == 1) replace_x(dice);
                }
        }

        for(i = 0; i < 3; i++) {
                if(dice->suf[FRONT] == s_FRONT) {
                        flag_FRONT = 1;
                        break;
                }
                replace_z(dice);
        }
        if(flag_TOP == 1 && flag_FRONT == 1) return 0;
        else return 1;
}

short compare_dice(dice_state_t *dice1, dice_state_t *dice2) {
        short i, j, k, l, flag;
        for(i = 0; i < 2; i++) {
                for(j = 0; j < 4; j++) {
                        for(k = 0; k < 4; k++) {
                                flag = 1;
                                for(l = 1; l < 7; l++) {
                                        if(dice2->suf[l] != dice1->suf[l]) {
                                                flag = 0;
                                                break;
                                        }
                                }
                                if(flag == 1) return 0;
                                replace_z(dice2);
                        }
                        if(i == 0) replace_y(dice2);
                        else if(i == 1) replace_x(dice2);
                }
        }
        return 1;

}


void replace_y(dice_state_t *dice) {
        short buf;

        buf = dice->suf[TOP];
        dice->suf[TOP] = dice->suf[FRONT]; // 1 -> 2
        dice->suf[FRONT] = dice->suf[BOTTOM]; // 2 -> 6
        dice->suf[BOTTOM] = dice->suf[BACK]; // 6 -> 5
        dice->suf[BACK] = buf; // 5 -> 1
}


void replace_x(dice_state_t *dice) {
        short buf;

        buf = dice->suf[TOP];
        dice->suf[TOP] = dice->suf[LEFT]; // 1 -> 4
        dice->suf[LEFT] = dice->suf[BOTTOM]; // 4 -> 6
        dice->suf[BOTTOM] = dice->suf[RIGHT]; // 6 -> 3
        dice->suf[RIGHT] = buf; // 3 -> 1
}

void replace_z(dice_state_t *dice) {
        short buf;

        buf = dice->suf[FRONT];
        dice->suf[FRONT] = dice->suf[RIGHT]; // 2 -> 3
        dice->suf[RIGHT] = dice->suf[BACK]; // 3 -> 5
        dice->suf[BACK] = dice->suf[LEFT]; // 5 -> 4
        dice->suf[LEFT] = buf; // 4 -> 2
}



Measured memory_bytes: 2140