#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

bool flag = false;

class Dice{
    public:
        void set(int num[6]);
        int get_number(int num);
        void E(), N(), S(), W();
        void lateral_rotation();
    private:
    int dice_number[6];
};

int Dice::get_number(int num){
    return dice_number[num];
}
void Dice::set(int num[6]){
    for(int i = 0; i < 6; i++) dice_number[i] = num[i];
}

void Dice::E(){
    int tmp = dice_number[0];
    dice_number[0] = dice_number[3];
    dice_number[3] = dice_number[5];
    dice_number[5] = dice_number[2];
    dice_number[2] = tmp;
}

void Dice::N(){
    int tmp = dice_number[0];
    dice_number[0] = dice_number[1];
    dice_number[1] = dice_number[5];
    dice_number[5] = dice_number[4];
    dice_number[4] = tmp;
}
void Dice::S(){
    int tmp = dice_number[0];
    dice_number[0] = dice_number[4];
    dice_number[4] = dice_number[5];
    dice_number[5] = dice_number[1];
    dice_number[1] = tmp;
}
void Dice::W(){
    int tmp = dice_number[0];
    dice_number[0] = dice_number[2];
    dice_number[2] = dice_number[5];
    dice_number[5] = dice_number[3];
    dice_number[3] = tmp;
}
void Dice::lateral_rotation(){
    int tmp = dice_number[1];
    dice_number[1] = dice_number[3];
    dice_number[3] = dice_number[4];
    dice_number[4] = dice_number[2];
    dice_number[2] = tmp;
}
bool check_dices(Dice dice1, Dice dice2){
    //全ての面が一致しているか確認する
    for(int i = 0; i < 6; i++){
        if(dice1.get_number(i) != dice2.get_number(i)){
            return false;
        }
    }
    return true;
}

int main(){
    Dice dice1, dice2;
    int dice_num1[6], dice_num2[6];
    char order[100];
    //サイコロを入力
    for (int i = 0; i < 6; i++ ) cin >> dice_num1[i];
    dice1.set( dice_num1 );
    for (int i = 0; i < 6; i++ ) cin >> dice_num2[i];
    dice2.set( dice_num2 );    

    //1が上面の時
    for (int i = 0; i < 4; i++){
        if(check_dices(dice1, dice2) == true){
            cout << "Yes" << endl;
            return 0;
        }
        dice2.lateral_rotation();
    }

    //2が上面の時
    dice2.N();
    for (int i = 0; i < 4; i++){
        if(check_dices(dice1, dice2) == true){
            cout << "Yes" << endl;
            return 0;
        }
        dice2.lateral_rotation();
    }

    //6
    dice2.N();
    for (int i = 0; i < 4; i++){
        if(check_dices(dice1, dice2) == true){
            cout << "Yes" << endl;
            return 0;
        }
        dice2.lateral_rotation();
    }

    //5
    dice2.N();
    for (int i = 0; i < 4; i++){
        if(check_dices(dice1, dice2) == true){
            cout << "Yes" << endl;
            return 0;
        }
        dice2.lateral_rotation();
    }

    //3
    dice2.W();
    for (int i = 0; i < 4; i++){
        if(check_dices(dice1, dice2) == true){
            cout << "Yes" << endl;
            return 0;
        }
        dice2.lateral_rotation();
    }

    //4
    dice2.E();
    dice2.E();
    for (int i = 0; i < 4; i++){
        if(check_dices(dice1, dice2) == true){
            cout << "Yes" << endl;
            return 0;
        }
        dice2.lateral_rotation();
    }

    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3096