#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i, n, init) for (ll i = init; i < (n); i++)
#define repd(i, n, init) for (ll i = (n); i >= init; i--)
#define repm(i, m) for (auto i = m.begin(); i != m.end(); i++)
#define repb(bit, n, init) for (ll bit = init; bit < (1 << n); ++bit)

class Dice
{
public:
    Dice()
    {
        number = new int[6];
        tmp = new int[6];
    };
    ~Dice()
    {
        delete[] number;
        delete[] tmp;
    };
    void setLabel(int index, int num)
    {
        number[index] = num;
    };

    void roll(char dst)
    {
        repi(i, 6, 0)
        {
            tmp[i] = number[i];
        }
        switch (dst)
        {
        case 'E':
            setNumber(tmp[3], tmp[1], tmp[0], tmp[5], tmp[4], tmp[2]);
            break;
        case 'S':
            setNumber(tmp[4], tmp[0], tmp[2], tmp[3], tmp[5], tmp[1]);
            break;
        case 'W':
            setNumber(tmp[2], tmp[1], tmp[5], tmp[0], tmp[4], tmp[3]);
            break;
        case 'N':
            setNumber(tmp[1], tmp[5], tmp[2], tmp[3], tmp[0], tmp[4]);
            break;

        default:
            break;
        }
    };
    int showPeek()
    {
        return number[0];
    };
    int showRight()
    {
        return number[2];
    };
    int showFront()
    {
        return number[1];
    };
    int showleft()
    {
        return number[3];
    };
    int showBack()
    {
        return number[4];
    };
    int showBottom()
    {
        return number[5];
    }
    int searchRight(int front, int peek)
    {
        int Ans = -1;
        repi(i, 8, 0)
        {
            if (number[1] == front && number[0] == peek)
            {
                Ans = number[2];
            }
            else if (number[2] == front && number[0] == peek)
            {
                Ans = number[4];
            }
            else if (number[4] == front && number[0] == peek)
            {
                Ans = number[3];
            }
            else if (number[3] == front && number[0] == peek)
            {
                Ans = number[1];
            }
            if (i >= 4)
            {
                roll('E');
            }
            else
            {
                roll('N');
            }
        }
        return Ans;
    };
    bool compare(Dice dice)
    {
        bool state = false;
        string order = "NNNNWNNNWNNNENNNENNNWNNN";
        repi(j, order.length(), 0)
        {
            roll(order.at(j));
            ll front = dice.showFront(), peek = dice.showPeek(), right = dice.showRight(), left = dice.showleft(), back = dice.showBack(), bottom = dice.showBottom();
            if (front == showFront() &&
                peek == showPeek() &&
                right == showRight() &&
                left == showleft() &&
                back == showBack() &&
                bottom == showBottom())
            {
                state = true;
            }
        }
        return state;
    };
    bool isSameDice(int inputed[])
    {
        char order[25] = "NNNNWNNNWNNNENNNENNNWNNN";
        for (int i = 0; i < 24; i++)
        {
            roll(order[i]);
            for (int j = 0; j < 6; j++)
            {
                if (inputed[j] != number[j])
                    break;
                if (j == 5)
                    return true;
            }
        }
        return false;
    };

private:
    void setNumber(int n0, int n1, int n2, int n3, int n4, int n5)
    {
        number[0] = n0;
        number[1] = n1;
        number[2] = n2;
        number[3] = n3;
        number[4] = n4;
        number[5] = n5;
    };
    //declar variables
    int *number;
    int *tmp;
};

int main()
{
    Dice dice1, dice2;
    repi(i, 6, 0)
    {
        int tmp;
        cin >> tmp;
        dice1.setLabel(i, tmp);
    }
    int inputed[6];
    repi(i, 6, 0)
    {
        int tmp;
        cin >> tmp;
        inputed[i] = tmp;
        dice2.setLabel(i, tmp);
    }
    cout << (dice1.compare(dice2) ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 3200