//
//  main.cpp
//  Test
//
//  Created by Nag on 2017/08/18.
//  Copyright ?? 2017??´ Nag. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <vector>
#include <sstream>
#include <string>
#include <cstdio>
#include <array>

using namespace std;

class Dice {
    int num_up;
    int num_s;
    int num_w;
    int num_n;
    int num_e;
    int num_bot;
    
public:
    //???????????????????????????
    Dice()
    {
        num_up = num_s = num_w = num_n = num_e = num_bot = 0;
    }
    
    Dice(int num1, int num2, int num3, int num4, int num5, int num6)
    : num_up( num1 )
    , num_s( num2 )
    , num_e( num3 )
    , num_w( num4 )
    , num_n( num5)
    , num_bot( num6 )
    {
    }
    
    Dice(string str)
    {
        stringstream ss(str);
        ss >> num_up >> num_s >> num_e >> num_w >> num_n >> num_bot;
    }
    
    //static??¢??°??????
    static bool isSameDice(Dice x, Dice y) {
        int cntVerticalSpin = 0;
        int cntHorizontalSpin = 0;
        
//        //for debug
//        cout << "y\n";
//        y.printDevelopment();
//        cout << "x\n";
//        x.printDevelopment();
        
        
        //x,y????????¢????????´???????????§x?????¨???????????¢?????????
        for( cntVerticalSpin=0; cntVerticalSpin<4; cntVerticalSpin++) {
            
            for( cntHorizontalSpin=0; cntHorizontalSpin<4; cntHorizontalSpin++ ) { //cnt=0,1,2,3??§?¨?4?????¢??????1??¨??????
                if( x.num_up == y.num_up && x.num_s == y.num_s && x.num_e == y.num_e && x.num_w == y.num_w && x.num_n == y.num_n && x.num_bot == y.num_bot ) {
                    
//                    //for debug
//                    x.printDevelopment();
                    
                    return true;
                } else {
                    x.spinRight();
                    
//                    //for debug
//                    cout << "\n?¨????" << cntHorizontalSpin << "?????¢??????" << endl;
//                    x.printDevelopment();

                }
            }
            
            x.rollToN(); //cnt=0,1,2,3??§???4?????¢??????1??¨??????
            
//            //for debug
//            cout << "\n??????" << cntVerticalSpin << "?????¢?????? -----------------------------------" << endl;
//            x.printDevelopment();
            
        } //???????????§??§up,front,back,bot????????¢???????????¨????????¢?´¢??????????????????left,right????????¢???????????±??????
        
        //right????????¢????????£?????????
        x.spinRight();
        x.rollToN();
        
//        //for debug
//        cout << "\nright????????¢????????£???????????? =============================================" << endl;
//        x.printDevelopment();
        
        
        
        for( cntVerticalSpin=0; cntVerticalSpin<2; cntVerticalSpin++) { //left,right????????¢?????????2??±????????????????????°??????
            
            for( cntHorizontalSpin=0; cntHorizontalSpin<4; cntHorizontalSpin++ ) { //cnt=0,1,2,3??§?¨?4?????¢??????1??¨??????
                if( x.num_up == y.num_up && x.num_s == y.num_s && x.num_e == y.num_e && x.num_w == y.num_w && x.num_n == y.num_n && x.num_bot == y.num_bot ) {

//                    //for debug
//                    cout << "?????´????????????\n";
//                    cout << "x\n";
//                    x.printDevelopment();
//                    cout << "y\n";
//                    y.printDevelopment();
                    
                    return true;
                } else {
                    x.spinRight();
                    
//                    //for debug
//                    cout << "\n?¨????" << cntHorizontalSpin << "?????¢??????" << endl;
//                    x.printDevelopment();
                }
            }
            
            //2?????¢??????left????????¢?????£????????????right????????¢????????£?????????
            x.rollToN();
            x.rollToN();
            
//            //for debug
//            cout << "\n??????" << cntVerticalSpin << "?????¢?????? -----------------------------------" << endl;
//            x.printDevelopment();
            
        } //????????§??¨????????????
        
        //??¨???????????¢?????????????????´???????????£????????§x??¨y?????°??????
        return false;
    }
    
    //??\??????????????¢??°??????
    int getUpperNumber(void) {
        return num_up;
    }
    
    int getFrontNumber(void) {
        return num_s;
    }
    
    int getRightNumber(void) {
        return num_e;
    }
    
    void printAllNumber(void) {
            cout << num_up << " " << num_s << " " << num_e << " " << num_w << " " << num_n << " " << num_bot << endl;
    }
    
    void printDevelopment(void) {
        cout << "     ---\n";
        cout << "    |" << setw(3) << num_up << "|       " << "\n";
        cout << " --- --- --- ---\n";
        cout << "|" << setw(3) << num_w << "|" << setw(3) << num_s << "|" << setw(3) << num_e << "|" << setw(3) << num_n << "|\n";
        cout << " --- --- --- ---\n";
        cout << "    |" << setw(3) << num_bot << "|\n";
        cout << "     ---\n";
        //     ---
        //    |100|
        // --- --- --- ---
        //|xx3|  x|xxx|xxx|
        // --- --- --- ---
        //    |xxx|
        //     ---
    }
    
    void rollToN() {
        int tmp;
        tmp = num_bot;
        num_bot = num_n;
        num_n = num_up;
        num_up = num_s;
        num_s = tmp;
    }
    
    void rollToS() {
        int tmp;
        tmp = num_bot;
        num_bot = num_s;
        num_s = num_up;
        num_up = num_n;
        num_n = tmp;
    }
    
    void rollToE() {
        int tmp;
        tmp = num_bot;
        num_bot = num_e;
        num_e = num_up;
        num_up = num_w;
        num_w = tmp;
    }
    
    void rollToW() {
        int tmp;
        tmp = num_bot;
        num_bot = num_w;
        num_w = num_up;
        num_up = num_e;
        num_e = tmp;
    }
    
    void spinRight() {
        int tmp;
        tmp = num_s;
        num_s = num_e;
        num_e = num_n;
        num_n = num_w;
        num_w = tmp;
    }
    
    void rollCommandWithChar(char c) {
        switch (c) {
            case 'E':
                rollToE();
                break;
                
            case 'N':
                rollToN();
                break;
                
            case 'S':
                rollToS();
                break;
                
            case 'W':
                rollToW();
                break;
                
            default:
                break;
        }
    }
    
    bool rollUntilThisUpperFront(int upper, int front) {
        int cnt;
        
        //?????¢??????????????°??????????????§??¨??????????????¢?????????
        cnt = 0;
        while(getUpperNumber() != upper) {
            if(cnt<3) { //cnt=0,1,2??§3?????¢
                rollToN();
                cnt++;
            } else if(cnt==3) {
                spinRight();
                cnt++;
            } else if(cnt<7) { //4,5,6??§3?????¢
                rollToN();
                cnt++;
            } else {
//                cout << "ERROR!! : UPPER is Not Found" << endl;
                return false;
            }
        }
        
//        //test display
//        printDevelopment();
        
        
        //?????¢??????????????°??????????????§??´??¢???????????¢
        cnt = 0;
        while(getFrontNumber() != front) {
            if(cnt<3) { //cnt=0,1,2??§3?????¢
                spinRight();
                cnt++;
            } else {
//                cout << "ERROR!! : FRONT is Not Found" << endl;
                return false;
            }
        }
        
//        //test display
//        printDevelopment();
        
        return true;
    }
};


int main(void) {
    string str;

    getline(cin, str);
    Dice x(str);
    //    Dice x("1 2 4 8 16 32");

    getline(cin, str);
    Dice y(str);
    
    
//    cout << "y\n";
//    y.printDevelopment();
//    cout << "x\n";
//    x.printDevelopment();
    
    if( Dice::isSameDice(x, y) == true )
        cout << "Yes\n";
    else
        cout << "No\n";
    
    return 0;
    
}



/*

1 2 3 4 5 6
1 2 4 8 16 32
SE



1 2 3 4 5 6
3
6 5
1 3
3 2


1 2 3 4 5 6
6 2 4 3 5 1

 

1 2 3 4 5 6
7 2 4 3 5 1

 */







////////////////////////////////////////
//AtCoder Grand Contest 019
//C - Fountain Walk
//
//????§£?±????LIS???????????°?§£???????????????
////////////////////////////////////////
//
//int main(void) {
//    const int INF = (int)2e9;
//    
//    cout << INF << endl;
//    
//    int x,y,  x1,y1,  x2,y2,  x3,y3;
//    int numOfFountain;
//    int i;
//    double totalDistance;
//    int cnt;
//    int distToNextFountainX, distToNextFountainY;
//    
//    vector<pair<int,int>> xdirectionalFountainData; //??¢?´¢??????????????´?°´?????§?¨????x??§?¨???§???????????????????´???????
//    vector<pair<int,int>> ydirectionalFountainData; //y??§???????????¨
//    
//    //read input data
//    cin >> x1 >> y1 >> x2 >> y2;
//    cin >> numOfFountain;
//
//
//    //??´?°´?????????????????????????????¢?´¢????????????????????????????£??????????
//    for(i=0; i<numOfFountain; i++) {
//        cin >> x >> y;
//        
//        if( (x1<=x2 && x1<=x && x<=x2) && (y1<=y2 && y1<=y && y<= y2) ) {//x1,y1?????????O??¨????????§?¨?????????????x2,y2????????????????????´???
//            pair<int, int> xy = {x-x1, y-y1}; //x1,y1????????????????????§?¨????????????????????????????????´???????
//            pair<int, int> yx = {y-y1, x-x1}; //ydirectional??¨
//            
//            xdirectionalFountainData.push_back(xy);
//            ydirectionalFountainData.push_back(yx);
//        }
//        else if( (x1<=x2 && x1<=x && x<=x2) && (y2<y1 && y2<=y && y<= y1) ) {//?????? (??????A)
//            pair<int, int> xy = {x-x1, -(y-y1)}; //x1,y1????????????????????§?¨????????????????????????????????´??????????y???y1??????????????§?????£?????????????´?
//            pair<int, int> yx = {-(y-y1), x-x1}; //ydirectional??¨
//            
//            xdirectionalFountainData.push_back(xy);
//            ydirectionalFountainData.push_back(yx);
//        }
//        else if( (x2<x1 && x2<=x && x<=x1) && (y1<y2 && y1<=y && y<= y2) ) {//?????? (??????B)
//            pair<int, int> xy = {-(x-x1), y-y1}; //x1,y1????????????????????§?¨????????????????????????????????´??????????x-x1??????????????§?????£?????????????´?
//            pair<int, int> yx = {y-y1, -(x-x1)}; //ydirectional??¨
//            
//            xdirectionalFountainData.push_back(xy);
//            ydirectionalFountainData.push_back(yx);
//        }
//        else if( (x2<x1 && x2<=x && x<=x1) && (y2<y1 && y2<=y && y<= y1) ) {//?????? (??????C)
//            pair<int, int> xy = {-(x-x1), -(y-y1)}; //x1,y1????????????????????§?¨????????????????????????????????´??????????x-x1???y???y1??????????????§?????£?????????????´?
//            pair<int, int> yx = {-(y-y1), -(x-x1)}; //ydirectional??¨
//            
//            xdirectionalFountainData.push_back(xy);
//            ydirectionalFountainData.push_back(yx);
//        }
//        else {
//            //????????\????????¢?´¢?????????????????§?????????????£?????????????
//        }
//        
//    }
//    
//    //x1,y1??§??£?????????????????§?????????O??????x3,y3 (??¨????????£) ?????§????????¢????±?????????°???????????¨?????????
//    x3 = abs(x2-x1);
//    y3 = abs(y2-y1);
//    xdirectionalFountainData.push_back( {x3+1, y3+1} ); //??´?°´????????????????????????????????¨????????\????????????
//    ydirectionalFountainData.push_back( {y3+1, x3+1} ); //????????????????£?????????¨????????????????????£?????¶?????§erase?????????????????????
//
//    
//    //sort FountainData
//    sort( xdirectionalFountainData.begin(), xdirectionalFountainData.end() );
//    sort( ydirectionalFountainData.begin(), ydirectionalFountainData.end() );
//    
//    
//    
//    //Test display
//    cout << endl << "x???" << endl;
//    for(auto v : xdirectionalFountainData) cout << v.first << " " << v.second << endl;
//    
//    cout << endl << "y???" << endl;
//    for(auto v : ydirectionalFountainData) cout << v.first << " " << v.second << endl;
//    
//    cout << endl << x3 << " " << y3 << endl;
//    
//    xdirectionalFountainData.erase( xdirectionalFountainData.begin() );
//    cout << endl << "x???" << endl;
//    for(auto v : xdirectionalFountainData) cout << v.first << " " << v.second << endl;
//    
//    
//
//    
////    //????°??????¢????±?????????¢?????´?????????
//    x = y = 0; //??????O??????????????????
//    totalDistance = 0; //???????????§??????????????¢?????????????????´?°´???1/4??¨???????????????????????????????????§?????¨??????????????????
//    cnt = 0; //??´?°´???1/4??¨?????????????????°
//    
//    while( !(x==x3 && y==y3) ) {
//        
//        //Algorithm II. x???????????´?°´??¨y???????????´?°´????????????????????????1????????????
//        distToNextFountainX = distToNextFountainY = -1;
//        
//        //???????????????????????´?°´???????????????????£?
//        while( xdirectionalFountainData[0].first < x ) xdirectionalFountainData.erase( xdirectionalFountainData.begin() );
//        while( ydirectionalFountainData[0].first < y ) ydirectionalFountainData.erase( ydirectionalFountainData.begin() );
//
//        //x???????????´?°´?????¢?´¢
//        if( y == ydirectionalFountainData[0].first ) {
//            distToNextFountainX = ydirectionalFountainData[0].second - x;
//        }
//        //y???????????´?°´?????¢?´¢
//        if( x == xdirectionalFountainData[0].first ) {
//            distToNextFountainY = xdirectionalFountainData[0].second - y;
//        }
//
//
//    
//    return 0;
//}


/*
 
 Case) Normal
 1 1 6 5
 5
 3 2
 5 3
 2 4
 4 8
 0 0
 
 Caase) A
 1 5 6 1
 5
 3 2
 5 3
 2 4
 4 8
 0 0
 
 Case) B
 6 1 1 5
 5
 3 2
 5 3
 2 4
 4 8
 0 0
 
 Case) C
 6 5 1 1
 5
 3 2
 5 3
 2 4
 4 8
 0 0
 
 */








//int main(void) {
//    for(int i=0; i<129; i++) {
//        char c = i;
//        cout << setw(3) << i << " : " << c << endl;
//    }
//    
//    
//    return 0;
//}
//
//
//33 : !
//34 : "
//35 : #
//36 : $
//37 : %
//38 : &
//39 : '
//40 : (
//      41 : )
//42 : *
//43 : +
//44 : ,
//45 : -
//46 : .
//47 : /
//48 : 0
//49 : 1
//50 : 2
//51 : 3
//52 : 4
//53 : 5
//54 : 6
//55 : 7
//56 : 8
//57 : 9
//58 : :
//59 : ;
//60 : <
//61 : =
//62 : >
//63 : ?
//64 : @
//65 : A
//66 : B
//67 : C
//68 : D
//69 : E
//70 : F
//71 : G
//72 : H
//73 : I
//74 : J
//75 : K
//76 : L
//77 : M
//78 : N
//79 : O
//80 : P
//81 : Q
//82 : R
//83 : S
//84 : T
//85 : U
//86 : V
//87 : W
//88 : X
//89 : Y
//90 : Z
//91 : [
//      92 : \
//      93 : ]
//94 : ^
//95 : _
//96 : `
//97 : a
//98 : b
//99 : c
//100 : d
//101 : e
//102 : f
//103 : g
//104 : h
//105 : i
//106 : j
//107 : k
//108 : l
//109 : m
//110 : n
//111 : o
//112 : p
//113 : q
//114 : r
//115 : s
//116 : t
//117 : u
//118 : v
//119 : w
//120 : x
//121 : y
//122 : z
//123 : {
//    124 : |
//    125 : }
//126 : ~
//127 : 
//128 : \200










////////////////////////////////////////
//AtCoder Grand Contest 019
//B - Reverse and Compare
//
//?¨???????????????¨??¶?????£?§£????§£??¬????¨????????????§?????????
////////////////////////////////////////
//void reverseStr(const string& in, int from, int to, string& out) {
//    string tmp = in.substr(from, to-from+1);
//    string rev_tmp;
//    
//    int n = tmp.size();
//    for(int i=0; i<n; i++) {
//        rev_tmp += tmp[n-1-i];
//    }
//    
//    //??????????°???\???????????????reverse(str.begin(), str.end()); ??¨??????????????????????????????????????§
//    //??????????????£??????????????£??????????????????????????????????????????
//    
////    out = in.substr(0, from-0) + " " + rev_tmp + " " + in.substr(to+1, in.size()-to-1);
//    out = in.substr(0, from-0) + rev_tmp + in.substr(to+1, in.size()-to-1);
//}
//
//
//int main(void) {
//    string str, ans;
//    cin >> str;
//    
////    str = "1234";
//    
//    int i, j, N;
//    N = str.size();
//    
//
//    
//    vector<string> list;
//
//    //???????????????
//    list.push_back(str);
//    
//    //??¨???????????????????¨????
//    for(i=0; i<N-1; i++) {
//        for(j=i+1; j<N; j++) {
//            reverseStr(str, i, j, ans);
//            
//            //??¢???????????????????????????????????¨?????????????????????????????§??????
//            bool duplicate_check = false;
//            for( auto itr : list ) {
//                if( itr == ans ) {
//                    duplicate_check = true;
//                    break;
//                }
//            }
//            
//            //????????????????????°??????????????????
//            if( !duplicate_check ) list.push_back(ans);
//        }
//    }
//    
////    //display all of list
////    for( auto itr : list) {
////        cout << itr << endl;
////    }
//    
//    //?????°?????????
//    cout << list.size() << endl;
//
//    
//    return 0;
//}






////////////////////////////////////////
//AtCoder Grand Contest 019
//A - Ice Tea Store
//
//??????
//https://teratail.com/questions/42794
//http://vivi.dyndns.org/tech/cpp/array-container.html
//
//?¨?????§£?????¨????????????N?????´??°?????£????????§???Q???H???S??¨???????????±??£?????????3??????????°????S?????????????¶??°???\?????§???????????????
////////////////////////////////////////
//int main(void) {
//    long long Q, H, S, D, N;
//
//    cin >> Q >> H >> S >> D >> N;
//    
//    N = N*1000;
//    
//    //?????§?¬¬???????´????????????????????????§?????????????????????????????????????¬?????????????array??§??????
//    //??????long long??§??±?????????????????????????????????????????????????????????????????¨?¨???§??¨?????????
//    array<long long,4> data[] = {                                                                  //????????????????????????????????????????????????????????????
//        {250, Q, Q*4*2, 0}, //????????????????????????"2"???????????????????????????????????\??????????????°
//        {500, H, H*2*2, 0}, //             ???????????????????°?????????????????????????????¨??????´??£??????N??¨???????????????????????°??????
//        {1000, S, S*2, 0},
//        {2000, D, D, 0}
//    };
//
////    //display data[][]
////    cout << endl;
////    for(int i=0; i<4; i++) {
////        for(int j=0; j<4; j++) {
////            cout << data[i][j] << "  ";
////        }
////        cout << endl;
////    }
////    
//    
//    //????????????????????????????????????????????????
//    sort(&data[0], &data[4], [](array<long long,4>& x, array<long long,4>& y){return x[2] < y[2];} ); //????????????????????????????????????????????????????????????
//    
//    
////    //display data[][]
////    cout << endl;
////    for(int i=0; i<4; i++) {
////        for(int j=0; j<4; j++) {
////            cout << data[i][j] << "  ";
////        }
////        cout << endl;
////    }
////    
//    
//    //????¨????N??¨??????????????????????????????????????\
//    long long sum = 0;
//    int cost = 0;
//    
//    for(int i=0; i<4; i++) {
//        while( sum + data[i][0] <= N ) {
//                sum += data[i][0];
//                cost += data[i][1];
//                data[i][3]++;
//        }
//    }
//    
//
////    //display data[][]
////    cout << endl;
////    for(int i=0; i<4; i++) {
////        for(int j=0; j<4; j++) {
////            cout << data[i][j] << "  ";
////        }
////        cout << endl;
////    }
////    
//    //display cost
//    cout << cost << endl;
//    
//    return 0;
//    
//}

Measured memory_bytes: 3156