#include<iostream>
using namespace std;
#include<stdio.h>

class dice {
        private:
                int temp_t;
                int temp_e;
                int temp_s;
                int temp_b;
                int temp_w;
                int temp_n;
        public:
                int top;
                int east;
                int south;
                int bottom;
                int west;
                int north;

                dice(int _top, int _east, int _south, int _bottom, int _west, int _north);
                void roll(char dir);
                bool isexist(int x);
                bool isSame(dice x);
                ~dice();
};

dice::dice(int _top, int _east, int _south, int _bottom, int _west, int _north){
        top = _top;
        east = _east;
        south = _south;
        bottom = _bottom;
        west = _west;
        north = _north;
}

void dice::roll(char dir){
        switch (dir){
                case 'N':
                        temp_n = north;
                        temp_t = top;
                        temp_s = south;
                        temp_b = bottom;
                        north = temp_t;
                        bottom = temp_n;
                        south = temp_b;
                        top = temp_s;
                        break;
                case 'S':
                        temp_n = north;
                        temp_t = top;
                        temp_s = south;
                        temp_b = bottom;
                        north = temp_b;
                        bottom = temp_s;
                        south = temp_t;
                        top = temp_n;
                        break;
                case 'E':
                        temp_e = east;
                        temp_t = top;
                        temp_w = west;
                        temp_b = bottom;
                        east = temp_t;
                        bottom = temp_e;
                        west = temp_b;
                        top = temp_w;
                        break;
                case 'W':
                        temp_e = east;
                        temp_t = top;
                        temp_w = west;
                        temp_b = bottom;
                        east = temp_b;
                        bottom = temp_w;
                        west = temp_t;
                        top = temp_e;
                        break;
                case 'R':
                        temp_e = east;
                        temp_w = west;
                        temp_n = north;
                        temp_s = south;
                        east = temp_s;
                        north = temp_e;
                        west = temp_n;
                        south = temp_w;
                        break;
                default:
                        cout << "Unknown Roll Command. Quit." << endl;
                        break;
        }
}

dice::~dice(){}

bool dice::isexist(int x) {
        if(top == x) return true;
        else if (bottom == x) return true;
        else if (east == x) return true;
        else if (west == x) return true;
        else if (north == x) return true;
        else if (south == x) return true;
        else return false;
}
bool dice::isSame(dice x) {
        if(x.top == top && x.bottom == bottom && x.east == east && x.west == west && x.north == north && x.south == south) return true;
        else return false;
}

int main() {
        int T, S, E, W, N, B;
        cin >> T >> S >> E >> W >> N >> B;
        dice diceA(T, E, S, B, W, N);
        cin >> T >> S >> E >> W >> N >> B;
        dice diceB(T, E, S, B, W, N);
        if(diceA.isexist(diceB.top) && diceA.isexist(diceB.bottom) && diceA.isexist(diceB.east)) {
                if(diceA.isexist(diceB.west) && diceA.isexist(diceB.north) && diceA.isexist(diceB.south)) {
                        for(int j = 0; j < 2; j++) {
                                if(diceA.top == diceB.north || diceA.top == diceB.south) diceB.roll('N');
                                for(int i = 0; i < 3; i++) {
                                        if(diceA.top == diceB.top && diceA.bottom == diceB.bottom) break;
                                        diceB.roll('E');
                                }
                                for(int i = 0; i < 3; i++) {
                                        if(diceA.south == diceB.south && diceA.north == diceB.north && diceA.east == diceB.east && diceA.west == diceB.west) break;
                                        diceB.roll('R');
                                }
                                if(diceA.isSame(diceB)) break;
                        }
                }
        }
        if(diceA.isSame(diceB)) cout << "Yes" << endl;
        else cout << "No" << endl;
        return 0;
}

Measured memory_bytes: 3112