#include <bits/stdc++.h>
using namespace std;

vector<int> rolledDice(char, vector<int>);

multiset<pair<int, int>> makeDistinctPairs(vector<int>);

int compareDice(vector<int>, vector<int>);

/* 0: t, 1: s, 2: e, 3: w, 4: n, 5: b */
int main()
{
    int n = 2;
    // cin >> n;

    vector<int> dice(6, 0);
    vector<vector<int>> dices(n, dice);

    for (int i = 0; i < n; i++)
    {
        for (int l = 0; l < 6; l++)
        {
            cin >> dices[i][l];
        }
    }

    multiset<pair<int, int>> distinctPairs = makeDistinctPairs(dices[0]); // 互いに等しいラベルの連中をゴソッと取り除いた集合

    if (distinctPairs.size() <= 9) // 1色（6面1色） or 2色（1面1色+5面1色）の場合
    {
        cout << "Yes" << endl;
        return 0;
    }
    else // 3色（2面2色+4面1色）以上の場合
    {
        // cout << "2 color" << endl;
        // {0, 1, 2}面（front, top, right）から配位が一意に確定しない状態を解消する
        for (int i = 0; i < n; i++)
        {
            if (dices[i][0] == dices[i][1] && dices[i][1] == dices[i][2])
            {
                dices[i] = rolledDice('N', dices[i]);
            }
        }
    }

    int equivalents = 0;
    for (int i = 0; i < n - 1; i++)
    {
        equivalents += compareDice(dices[i], dices[i + 1]);
    }
    
    if (equivalents == n - 1) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

int compareDice(vector<int> testingDice, vector<int> dice)
{
    int res = 0;

    if (testingDice[2] == dice[1])
    {
        testingDice = rolledDice('W', testingDice);
        testingDice = rolledDice('S', testingDice);
    }
    else if (testingDice[3] == dice[1])
    {
        testingDice = rolledDice('E', testingDice);
        testingDice = rolledDice('S', testingDice);
    }
    else
    {
        while (testingDice[1] != dice[1])
        {
            testingDice = rolledDice('N', testingDice);
        }
    }

    if (testingDice[4] != dice[0])
    {
        while (testingDice[0] != dice[0])
        {
            testingDice = rolledDice('E', testingDice);
        }
    }

    if (testingDice == dice)
    {
        res++;
    }

    return res;
}

vector<int> rolledDice(char direction, vector<int> olddice)
{
    vector<int> newdice = olddice;
    if (direction == 'N')
    {
        // cout << "rolling to " << direction << endl;
        newdice[0] = olddice[1];
        newdice[1] = olddice[5];
        newdice[5] = olddice[4];
        newdice[4] = olddice[0];
    }
    else if (direction == 'S')
    {
        // cout << "rolling to " << direction << endl;
        newdice[0] = olddice[4];
        newdice[4] = olddice[5];
        newdice[5] = olddice[1];
        newdice[1] = olddice[0];
    }
    else if (direction == 'E')
    {
        // cout << "rolling to " << direction << endl;
        newdice[0] = olddice[3];
        newdice[3] = olddice[5];
        newdice[5] = olddice[2];
        newdice[2] = olddice[0];
    }
    else if (direction == 'W')
    {
        // cout << "rolling to " << direction << endl;
        newdice[0] = olddice[2];
        newdice[2] = olddice[5];
        newdice[5] = olddice[3];
        newdice[3] = olddice[0];
    }
    return newdice;
}

multiset<pair<int, int>> makeDistinctPairs(vector<int> dice)
{
    multiset<pair<int, int>> res; // 互いに等しいラベルの連中をゴソッと取り除いた集合
    for (int i = 0; i < 6; i++)
    {
        for (int j = i + 1; j < 6; j++)
        {
            res.insert(make_pair(dice[i], dice[j]));
        }
    }
    for (int i = 0; i < 6; i++)
    {
        for (int j = i + 1; j < 6; j++)
        {
            if (dice[i] == dice[j])
            {
                res.erase(make_pair(dice[i], dice[j]));
            }
        }
    }

    return res;
}


Measured memory_bytes: 3168