#include <stdio.h>
#include <vector>
#include <array>
#include <string>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <unordered_map>

using std::string;
using std::vector;

class Dice {
private:
    // [ ][5][ ]
    // [4][1][3] 
    // [ ][2][ ] 
    int board[3][3];
    int bottom_;
public:
    Dice(vector<int> legends) {
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                board[i][j] = -1;
            }
        }
        this->board[0][1] = legends[5-1];
        this->board[1][0] = legends[4-1];
        this->board[1][1] = legends[1-1];
        this->board[1][2] = legends[3-1];
        this->board[2][1] = legends[2-1];
        this->bottom_ = legends[6-1]; 
    }
    void move(char direction) {
        switch (direction) {
            case 'N': {
                int tempBottom = board[0][1];
                board[0][1]    = board[1][1];
                board[1][1]    = board[2][1];
                board[2][1]    = this->bottom_;
                this->bottom_   = tempBottom;
                break;
            }

            case 'E': {
                int tempBottom = board[1][2];
                board[1][2]    = board[1][1];
                board[1][1]    = board[1][0];
                board[1][0]    = this->bottom_;
                this->bottom_   = tempBottom;
                break;
            }
            case 'W': {
                int tempBottom = board[1][0];
                board[1][0]    = board[1][1];
                board[1][1]    = board[1][2];
                board[1][2]    = this->bottom_;
                this->bottom_   = tempBottom;
                break;
            }
            case 'S': {
                int tempBottom = board[2][1];
                board[2][1]    = board[1][1];
                board[1][1]    = board[0][1];
                board[0][1]    = this->bottom_;
                this->bottom_   = tempBottom;
                break;
            }
        }
    }
    void printBoard() {
        printf("------------\n");
        for(int i = 0; i < 3; i++) {
            for(int j = 0; j < 3; j++){
                printf("[% d] ", this->board[i][j]);
            }
            printf("\n");
        }
    }    
    int top() {
        return this->board[1][1];
    }
    int front() {
        return this->board[2][1];
    }
    void front(int n){
        this->board[2][1] = n;
    }
    int left() {
        return this->board[1][0];
    }
    void left(int n){
        this->board[1][0] = n;
    }
    int right() {
        return this->board[1][2];
    }
    void right(int n) {
        this->board[1][2] = n;
    }
    int back() {
        return this->board[0][1];
    }
    void back(int n) {
        this->board[0][1] = n;
    }
    int bottom() {
        return this->bottom_;
    }
    void clockwise() {
        int temp = this->back();
        this->back(this->left());
        this->left(this->front());
        this->front(this->right());
        this->right(temp);
        // printBoard();
    }
    int getRight(int front) {
        for (int i = 0; i < 4; i++){
            this->clockwise();
            if (this->front() == front) return this->right();
        }
        return -2;
    }

    int searchRight(int top, int front) {
        for (int i = 0; i < 6; i++) {
            const char direction = i % 2 == 0 ? 'S' : 'W';
            this->move(direction);
            if (top == this->top()) {
                return this->getRight(front);
            } 
        }
        return -1;
    }
};
int main(){
    int n1, n2, n3, n4, n5, n6;
    scanf("%d %d %d %d %d %d", &n1, &n2, &n3, &n4, &n5, &n6);
    Dice diceA({ n1, n2, n3, n4, n5, n6 });
    scanf("%d %d %d %d %d %d", &n1, &n2, &n3, &n4, &n5, &n6);
    Dice diceB({ n1, n2, n3, n4, n5, n6 });

    for (int i = 0; i < 6; i++) {
        // 6面 search
        const char direction = i % 2 == 0 ? 'S' : 'W';
        // Bを回転させてtopが一致するところを探す
        diceB.move(direction);
        if (diceA.top() == diceB.top()) {
            for (int j = 0; j < 4; j++){
                diceB.clockwise();
                if (diceA.front() != diceB.front()) continue;
                if (diceA.back() != diceB.back()) continue;
                if (diceA.right() != diceB.right()) continue;
                if (diceA.left() != diceB.left()) continue;
                if (diceA.bottom() != diceB.bottom()) continue;
                
                printf("Yes\n");
                return 0;
            }

        }
    }
    printf("No\n");
    return 0;
}


Measured memory_bytes: 3240