#include <iostream>

struct Dice{
    int top, S, E, W, N, bottom;    
    void Set(int *Input);
    void Roll_N();
    void Roll_W();
    void Roll_S();
    void Roll_E();
    void Roll_cclockwise();
    bool Adjust_Top(int topface);
    bool Adjust_Front(int front);
    int Out_Right(int topface, int front);
};
void Dice::Set(int *Input)
{
    top = Input[0];
    S = Input[1];
    E = Input[2];
    W = Input[3];
    N = Input[4];
    bottom = Input[5];
}

void Dice::Roll_S()
{
    int temp;
    temp = top;
    top = N;
    N = bottom;
    bottom = S;
    S = temp;
}

void Dice::Roll_E()
{
    int temp;
    temp = top;
    top = W;
    W = bottom;
    bottom = E;
    E = temp;
}

void Dice::Roll_N()
{
    int temp;
    temp = top;
    top = S;
    S = bottom;
    bottom = N;
    N = temp;
}

void Dice::Roll_W()
{
    int temp;
    temp = top;
    top = E;
    E = bottom;
    bottom = W;
    W = temp;
}

void Dice::Roll_cclockwise()
{
    int temp;
    temp = W;
    W = N;
    N = E;
    E = S;
    S = temp;
}

bool Dice::Adjust_Top(int topface){
    //Adjust topface
    if (top == topface)
        return true;

    if (bottom == topface)
    {
        Roll_N();
        Roll_N();
    }
    else if (S == topface)
    {
        Roll_N();
    }
    else if (E == topface)
    {
        Roll_W();
    }
    else if (N == topface)
    {
        Roll_S();
    }
    else if (W == topface)
    {
        Roll_E();
    }
    if (top != topface)
        return false;

    return true;
}

bool Dice::Adjust_Front(int front)
{
    int num = 0;
    while (S != front)
    {
        Roll_cclockwise();
        if (num++ > 4)
            return false;
    }
    return true;
}

int Dice::Out_Right(int topface, int front)
{
    bool iftop, iffront;
    //Adjust topface
    iftop = Adjust_Top(topface);
    
    //Adjust front face
    iffront = Adjust_Front(front);
    if (!iftop || !iffront)
        return -1;

    return E;
}

int main(){
    int Input1[6], Input2[6];
    bool iftop, iffront;
    Dice Dice1, Dice2;
    
    //std::string command;
    for (int i = 0; i < 6; i++)
        std::cin >> Input1[i];
    for (int i = 0; i < 6; i++)
        std::cin >> Input2[i];
    Dice1.Set(Input1);
    Dice2.Set(Input2);

    iftop = Dice2.Adjust_Top(Dice1.top);
    iffront = Dice2.Adjust_Front(Dice1.S);
    for (int i = 0; i < 6;i++){
        for (int j = 0; j < 4;j++){
            if (iftop && iffront)
            {
                if (Dice1.E == Dice2.E && Dice1.N == Dice2.N && Dice1.W == Dice2.W && Dice1.bottom == Dice2.bottom)
                {
                    std::cout << "Yes" << std::endl;
                    return 0;
                }
            }
            Dice2.Roll_cclockwise();
        }                    
        iffront = Dice2.Adjust_Front(Dice1.S);
        if(i==0)
            Dice2.Roll_N();
        if(i==1)
            Dice2.Roll_N();
        if(i==2)
            Dice2.Roll_N();
        if(i==3){
            Dice2.Roll_S();
            Dice2.Roll_E();
        }
        if(i==4){
            Dice2.Roll_W();
            Dice2.Roll_W();
        }
        iftop = Dice2.Adjust_Top(Dice1.top);
    }
    std::cout << "No" << std::endl;

    return 0;
}


Measured memory_bytes: 3108