//
//  main.cpp
//  ITP1_11-A
//
//  Created by ?????¶??? on 15/8/15.
//  Copyright (c) 2015??´ ?????¶???. All rights reserved.
//

#include <iostream>
#include <vector>
#include <stdio.h>

using namespace std;

struct Dice{
    
    //  {?????????????????????????????????}
    //    0  1  2  3  4  5
    
    
    enum DICE_DIR{
      
        NONE = -1,
        TOP = 0,
        FRONT,
        RIGHT,
        LEFT,
        BACK,
        BOTTOM,
    };
    
    vector<int> originNumberPositions;
    
    vector<int> NumberPositions;
    
    void Move_E(){ //???
        
        int temp1 = NumberPositions[0];
        int temp2 = NumberPositions[5];
        
        NumberPositions[0] = NumberPositions[3];
        NumberPositions[5] = NumberPositions[2];
        
        NumberPositions[3] = temp2;
        NumberPositions[2] = temp1;
        
    }
    
    void Move_N(){ //???
        
        int temp1 = NumberPositions[0];
        int temp2 = NumberPositions[5];
        
        NumberPositions[0] = NumberPositions[1];
        NumberPositions[5] = NumberPositions[4];
        
        NumberPositions[4] = temp1;
        NumberPositions[1] = temp2;
        
    }
    
    void Move_S(){ //???
        
        int temp1 = NumberPositions[0];
        int temp2 = NumberPositions[5];
        
        NumberPositions[0] = NumberPositions[4];
        NumberPositions[5] = NumberPositions[1];
        
        NumberPositions[4] = temp2;
        NumberPositions[1] = temp1;
        
        
    }
    
    void Move_W(){ //???
        
        int temp1 = NumberPositions[0];
        int temp2 = NumberPositions[5];
        
        NumberPositions[0] = NumberPositions[2];
        NumberPositions[5] = NumberPositions[3];
        
        NumberPositions[3] = temp1;
        NumberPositions[2] = temp2;
        
    }
    
    // ??°?????\Y?????´???,????????¬??¨45???
    void Move_Left(){
        
        int temp1 = NumberPositions[1];
        int temp4 = NumberPositions[4];

        NumberPositions[1] = NumberPositions[3];
        NumberPositions[4] = NumberPositions[2];
        
        NumberPositions[2] = temp1;
        NumberPositions[3] = temp4;
    }
    
    void Move_right(){
        
        int temp1 = NumberPositions[1];
        int temp4 = NumberPositions[4];
        
        NumberPositions[1] = NumberPositions[3];
        NumberPositions[4] = NumberPositions[2];
        
        NumberPositions[2] = temp1;
        NumberPositions[3] = temp4;
    }

};

namespace Function {
    
    void restDice(Dice &dice){
        
        dice.NumberPositions = dice.originNumberPositions;
    }
    
    //????????°?????°??¨?????¨??°??????????????????
    Dice::DICE_DIR searchNumberPosition(Dice &dice, int number){
        
        for (int i = 0; i < 6; i++) {
            
            if (dice.NumberPositions[i] == number) {
                return static_cast<Dice::DICE_DIR>(i);
            }
        }
        
        return Dice::DICE_DIR::NONE;
    }
    
    // ?°?????????¢?????°??°?????¶??¨
    void moveNumberToTop(Dice &dice, Dice::DICE_DIR direction){
        
        switch (static_cast<Dice::DICE_DIR>(direction)) {
                
            case Dice::FRONT:
                
                dice.Move_N();
                break;
            case Dice::BACK:
                
                dice.Move_S();
                break;
            case Dice::LEFT:
                
                dice.Move_E();
                break;
            case Dice::RIGHT:
                
                dice.Move_W();
                break;
            case Dice::BOTTOM:
                
                dice.Move_N();
                dice.Move_N();
                
                break;
            default:
                break;
        }
        
//        for (auto &n : dice.NumberPositions){
//            printf("%d ", n);
//        }
        
    }
    
    std::vector<std::vector<int>> getAllPosition(Dice &dice){
        
        std::vector<std::vector<int>> allPositions;
        
        for(int i = 0; i < 6; ++i){
            
//            printf("dice.originNumberPositions[%d]: %d will set to top\n", i, dice.originNumberPositions[i]);
            restDice(dice);
            moveNumberToTop(dice, static_cast<Dice::DICE_DIR>(i));
            
            for (int j = 0; j < 4; ++j) {
                
                dice.Move_Left();
                allPositions.push_back(dice.NumberPositions);
                
//                for(auto & p : dice.NumberPositions){
//                    printf("%d\n", p);
//                }
//                
//                printf("\n");
            }
        }
        return allPositions;
    }
    
    
    bool isTheSameDice(Dice &dice_1, Dice &dice_2){
        
        std::vector<std::vector<int>> allPosition_1 = getAllPosition(dice_1);
        
//        printf("all position size: %d\n", static_cast<int>(allPosition_1.size()));
        
        
        for (int i = 0; i < 24; ++i) {
            
            
            for (int j = 0; j < 6; ++j) {
                
//                printf("all position[%d][%d] number: %d\n", i, j, allPosition_1[i][j]);
//                printf("dice_2[%d]: %d\n", j, dice_2.originNumberPositions[j]);
                
                if (allPosition_1[i][j] != dice_2.originNumberPositions[j]) {
                    break;
                }
                
                
                if (j == 5){
                    return true;
                }
            }
            
//            printf("\n");
        }
        
        return false;
        
    }

}

int main() {
    
    Dice dice_1;
    Dice dice_2;
    
    int temp;
    
    for (int i = 0; i < 6; i++) {
        
        cin >> temp;
        
        dice_1.NumberPositions.push_back(temp);
        dice_1.originNumberPositions.push_back(temp);
    }
    
    
    for (int i = 0; i < 6; i++) {
        
        cin >> temp;
        
        dice_2.NumberPositions.push_back(temp);
        dice_2.originNumberPositions.push_back(temp);
    }
    
    if (Function::isTheSameDice(dice_1, dice_2)) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1208