#include<bits/stdc++.h>
using std::cout;
using std::cin;
using std::endl;

bool Reoreder(std::vector<int> &v)
{
    int x = v[0];
    v.push_back(x);
    if (v.erase(v.begin()+1)==v.end()) //あれ？？？
    {
        cout << "Error: Can't erase "<< endl;
        return false;
    }
    return true;
}

class dice
{
    private:
        int roll[6];

    public:
        explicit dice(int in[6]){
            for (int i = 0; i < 6; i++)
                roll[i] = in[i];
        }

        void move(const char c){
            int tmp;
            switch(c){
                case 'N':
                    tmp = roll[0];
                    roll[0] = roll[1];
                    roll[1] = roll[5];
                    roll[5] = roll[4];
                    roll[4] = tmp;
                    break;

                case 'E':
                    tmp = roll[0];
                    roll[0] = roll[3];
                    roll[3] = roll[5];
                    roll[5] = roll[2];
                    roll[2] = tmp;
                    break;

                case 'W':
                    tmp = roll[0];
                    roll[0] = roll[2];
                    roll[2] = roll[5];
                    roll[5] = roll[3];
                    roll[3] = tmp;
                    break;

                case 'S':
                    tmp = roll[0];
                    roll[0] = roll[4];
                    roll[4] = roll[5];
                    roll[5] = roll[1];
                    roll[1] = tmp;
                    break;

                default:
                    cout << "Wrong Direction: "
                         << c << endl;
                    break;
            }
        }
        void roll_R()
        {
            int tmp;
            tmp = roll[1];
            roll[1] = roll[2];
            roll[2] = roll[4];
            roll[4] = roll[3];
            roll[3] = tmp;
        }

        int operator()(size_t i){
            return roll[i];
        }

        void show()
        {
            for (int i = 0; i < 6; i++)
                cout << roll[i] << " " << std::flush;
        }

        bool check(dice d)
        {
            for (int i = 0; i < 6; i++)
            {
                if (roll[i]!=d(i))
                    return false;
            }
            return true;
        }

        bool equvalent_to(dice d){
            int count=0;
            while (1)
            {
                count++;
                move('N');
                if (roll[0]==d(0)&&roll[5]==d(5))
                    break;
                move('W');
                if (roll[0]==d(0)&&roll[5]==d(5))
                    break;
                if (count>3) //top,bottomが一致することがなければサイコロ自体一致しない
                    return false;
            }
            //確定でtop,bottomが一致
            
            count = 0;
            while(1)
            {
                count++;
                if (check(d))
                    break;
                roll_R();
                if(count>5)
                    return false;
            }
            return true;  
        }


};
/*
bool check(dice &d1, dice d2)
{
    std::vector<int> order1(4), order2(4);

    int i = 0;
    while (i < 4)
    {
        if (d1(1)==d2(1))
            break;
        d1.move('N');
        i++;
    }

    if(d1(1)!=d2(1))
    {
        d1.move('W'); d1.move('N');
        if(d1(1)!=d2(1))
        {    d1.move('S'); d1.move('S');}
    }
    //ここで確実にd1(1)とd2(1)が一緒の値

    order1 = {d1(0), d1(1), d1(5), d1(4)};
    order2 = {d2(0), d2(1), d2(5), d2(4)};

    while (order1 != order2)
    {    
        for (i = 0; i < 3; i++)
        {
            if ((i!=1)&&(order1[i]==order2[1])) //frontと同じ数をもつ面があるかどうか
            {
                for (int j = 0; j < (i+3)%4; j++) //order1[i]が
                {
                    if (Reoreder(order1)==false)
                        break;
                }
            }
        }
    }    
    


    return false;
}*/

int main()
{
    int eye1[6], eye2[6];

    for (int i = 0; i < 6; i++)
        cin >> eye1[i];
    
    for (int i = 0; i < 6; i++)
        cin >> eye2[i];

    dice d1(eye1), d2(eye2);

    cout << (d1.equvalent_to(d2) ? "Yes" : "No") << endl;
    
    return 0;
}


Measured memory_bytes: 3112