#include <iostream>
#include <cstring>
using namespace std;

int test(string D[][6]);

int main()
{
        string Din[2][6], tmp;
        int t_ix, f_ix, flag = 0;
        for(int i = 0; i < 2; i++) {
                for(int j = 0; j < 6; j++) {
                        cin >> Din[i][j];
                }
        }

        for(int i = 0; i < 6; i++) {
                if(Din[0][0] == Din[1][i]) {
                        switch(i) {
                                case 0:
                                        flag = test(Din);
                                        break;
                                case 1:
                                        tmp = Din[1][0];
                                        Din[1][0] = Din[1][1];
                                        Din[1][1] = Din[1][5];
                                        Din[1][5] = Din[1][4];
                                        Din[1][4] = tmp; flag = test(Din);
                                        break;
                                case 2:
                                        tmp = Din[1][0];
                                        Din[1][0] = Din[1][2];
                                        Din[1][2] = Din[1][5];
                                        Din[1][5] = Din[1][3];
                                        Din[1][3] = tmp;

                                        flag = test(Din);
                                        break;
                                case 3:
                                        tmp = Din[1][0];
                                        Din[1][0] = Din[1][3];
                                        Din[1][3] = Din[1][5];
                                        Din[1][5] = Din[1][2];
                                        Din[1][2] = tmp;

                                        flag = test(Din);
                                        break;
                                case 4:
                                        tmp = Din[1][0];
                                        Din[1][0] = Din[1][4];
                                        Din[1][4] = Din[1][5];
                                        Din[1][5] = Din[1][1];
                                        Din[1][1] = tmp;

                                        flag = test(Din);
                                        break;
                                case 5:
                                        tmp = Din[1][0];
                                        Din[1][0] = Din[1][5];
                                        Din[1][5] = tmp;
                                        tmp = Din[1][1];
                                        Din[1][1] = Din[1][4];
                                        Din[1][4] = tmp;
                                        
                                        flag = test(Din);
                                        break;

                                default:
                                        break;
                        }
                }
        }

        if(flag) {
                cout << "Yes" << endl;
        } else {
                cout << "No" << endl;
        }

        return 0;
}

int test(string D[][6])
{
        int flag = 0;
        string tmp;

        if(D[0][5] == D[1][5]) {
                for(int j = 1; j <= 4; j++) {
                        if(D[0][1] == D[1][j]) {
                                switch(j) {
                                case 1:
                                        if(D[0][2] == D[1][2]) {
                                                flag = 1;
                                        }
                                        break;
                                case 2:
                                        tmp = D[1][1];
                                        D[1][1] = D[1][2];
                                        D[1][2] = D[1][4];
                                        D[1][4] = D[1][3];
                                        D[1][3] = tmp;
                                        if(D[0][2] == D[1][2]){
                                                flag = 1;
                                        }
                                        break;
                                case 3:
                                        tmp = D[1][1];
                                        D[1][1] = D[1][3];
                                        D[1][3] = D[1][4];
                                        D[1][4] = D[1][2];
                                        D[1][2] = tmp;
                                        if(D[0][2] == D[1][2]) {
                                                flag = 1;
                                        }
                                        break;
                                case 4:
                                        tmp = D[1][4];
                                        D[1][4] = D[1][1];
                                        D[1][1] = tmp;
                                        tmp = D[1][2];
                                        D[1][2] = D[1][3];
                                        D[1][3] = tmp;
                                        if(D[0][2] == D[1][2]) {
                                                flag = 1;
                                        }
                                        break;
                                default:
                                        break;
                                }
                        }
                }
        }

        return flag;
}



Measured memory_bytes: 3156