#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;

class dice
{
    int left, right, top, bottom, front, back;

public:
    void turn(char op);
    void getdice(int t, int f, int r, int l, int ba, int bo);
    void getdice2();
    void disptop();
    void dispright();
    void dispfront();
    void dispall();
    int getall(int a[6]);
    void moveto(int target1, int target2);
};

void dice::turn(char op)
{
    int tmp;
    if (op == 'E')
    {
        tmp = top;
        top = left;
        left = bottom;
        bottom = right;
        right = tmp;
    }
    else if (op == 'W')
    {
        tmp = top;
        top = right;
        right = bottom;
        bottom = left;
        left = tmp;
    }
    else if (op == 'N')
    {
        tmp = top;
        top = front;
        front = bottom;
        bottom = back;
        back = tmp;
    }
    else if (op == 'S')
    {
        tmp = top;
        top = back;
        back = bottom;
        bottom = front;
        front = tmp;
    }
}

void dice::getdice(int t, int f, int r, int l, int ba, int bo)
{
    left = l, right = r, top = t, bottom = bo, front = f, back = ba;
}

void dice::getdice2()
{
    cin >> top >> front >> right >> left >> back >> bottom;
}

void dice::disptop()
{
    cout << top << endl;
}

void dice::dispright()
{
    cout << right << endl;
}

void dice::dispfront()
{
    cout << front << endl;
}

void dice::dispall()
{
    cout << top << " " << front << " " << right << " " << left << " " << back << " " << bottom << endl;
}

int dice::getall(int a[])
{
    int d[6] = {top, front, right, left, back, bottom};
    for (int i = 0; i < 6; i++)
        a[i] = d[i];
    return 0;
}

void dice::moveto(int target1, int target2)
{
    if (target2 == top)
        turn('S');
    else if (target2 == left)
    {
        turn('E');
        turn('S');
    }
    else if (target2 == right)
    {
        turn('W');
        turn('S');
    }
    else if (target2 == back)
    {
        turn('S');
        turn('S');
    }
    else if (target2 == bottom)
        turn('N');

    if (target1 == right)
        turn('W');
    else if (target1 == left)
        turn('E');
    else if (target1 == bottom)
    {
        turn('E');
        turn('E');
    }
}

int dicematch(int al[], int bl[])
{
    int r = 0;
    int s = 0;
    for (int i = 0; i < 6; i++)
    {
        if (al[i] == bl[i])
            s++;
    }
    if (s == 6)
        r = 1;
    return r;
}

int dicematching(dice a, dice b)
{
    int r = 0;
    int al[6], bl[6], lenop;
    string op = "SSSSEEEESSSSSEEEESSSSSEEEESSSSSEEEESESSSSSEEEESSSSSSEEEE";
    lenop = op.size();
    b.getall(bl);

    for (int i = 0; i < lenop; i++)
    {
        a.turn(op[i]);
        a.getall(al);
        if (dicematch(al, bl))
        {
            r = 1;
        }
    }
    return r;
}

int main()
{
    int n, ans;
    ans = 0;
    n = 2;
    dice a[n];
    for (int i = 0; i < n; i++)
    {
        a[i].getdice2();
    }
    for (int i = 0; i < n - 1; i++)
    {
        for (int j = i + 1; j < n; j++)
        {
            ans += dicematching(a[i], a[j]);
        }
    }
    if (ans == 0)
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
    return 0;
}



Measured memory_bytes: 3212