#include<iostream>
#include<string>
using namespace std;

class dice
{
private:
    int asp[6];
    string order;
public:
    void setdice( int* j );                         //サイコロの値を格納
    void exchange( int& x, int& y );                //サイコロの場所を交換
    void orderX( string x );                        //転がす命令を行う
    void quetion( dice x );                         //質問の形にサイコロを動かす関数
    bool judge( dice a );                           //サイコロが一致しているか判定する関数
    bool new_judge( dice a );

    int* d_asp(){ return asp; }                     //サイコロのアドレスを返す関数
    int d_top(){ return asp[0]; }                   //上面を返す関数
    int d_bottom(){ return asp[5]; }                //底
    int d_right(){ return asp[2]; }                 //右
    int d_left(){ return asp[3]; }                  //左
    int d_front(){ return asp[1]; }                 //前
    int d_back(){ return asp[4]; }                  //後
};

void dice::setdice( int* j )
{
    for( int i = 0; i < 6; i++ )
        asp[i] = j[i];
}

void dice::exchange( int& x, int& y )
{
    int temp;
    temp = x;
    x = y;
    y = temp;
}

void dice::orderX( string x )
{

    for( int i = 0; i < x.size(); i++ )
    {

        if( x[i] == 'E' )
        {
            exchange( asp[0], asp[2] );
            exchange( asp[0], asp[5] );
            exchange( asp[0], asp[3] );
        }
        else if( x[i] == 'N' )
        {
            exchange( asp[0], asp[4] );
            exchange( asp[0], asp[5] );
            exchange( asp[0], asp[1] );
            
        }
        else if( x[i] == 'S' )
        {
            exchange( asp[0], asp[1] );
            exchange( asp[0], asp[5] );
            exchange( asp[0], asp[4] );
        }
        else if( x[i] == 'W' )
        {
            exchange( asp[0], asp[3] );
            exchange( asp[0], asp[5] );
            exchange( asp[0], asp[2] );
        }
        else if( x[i] == 'R' )
        {
            exchange( asp[1], asp[3] );
            exchange( asp[1], asp[4] );
            exchange( asp[1], asp[2] );
        }
        else{}
    }
}

void dice::quetion( dice x )
{
    int* j = x.d_asp();

    for( int i = 0; i < 3; i++ )
    {
        if( asp[0] == j[0] )
            break;
        else
            orderX("N");
    }

    for( int i = 0; i < 3; i++ )
    {
        if( asp[0] == j[0] )
            break;
        else
            orderX("E");
    }

    for( int i = 0; i < 3; i++ )
    {
        if( asp[1] == j[1] )
            break;
        else
            orderX("R");
    }

    for( int i = 0; i < 3; i++ )
    {
        if( asp[2] == j[2] )
            break;
        else
            orderX("E");
    }

    if( asp[0] != j[0] )
        return;

    for( int i = 0; i < 3; i++ )
    {
        if( asp[2] == j[2] )
            break;
        else
            orderX("R");
    }

    for( int i = 0; i < 3; i++ )
    {
        if( asp[3] == j[3] )
            break;
        else
            orderX("E");
    }

    for( int i = 0; i < 3; i++ )
    {
        if( asp[3] == j[3] )
            break;
        else
            orderX("R");
    }

    for( int i = 0; i < 3; i++ )
    {
        if( asp[4] == j[4] )
            break;
        else
            orderX("N");
    }
    for( int i = 0; i < 3; i++ )
    {
        if( asp[4] == j[4] )
            break;
        else
            orderX("R");
    }
    for( int i = 0; i < 3; i++ )
    {
        if( asp[5] == j[5] )
            break;
        else
            orderX("N");
    }
    for( int i = 0; i < 3; i++ )
    {
        if( asp[5] == j[5] )
            break;
        else
            orderX("E");
    }

}

bool dice::judge( dice a )
{
    bool flag = true;
    int* j = a.d_asp();                     //aのサイコロの配列を保持
 
    quetion( a );                           //dice aの向きに合わせて転がす

    for( int i = 0; i < 6; i++ )
    {
        if( asp[i] == j[i] )
            flag = true;
        else
        {
            flag = false;
            break;
        }
    }

    return flag;
}

bool dice::new_judge( dice a )
{
    bool flag = true;
    int* j = a.d_asp();                     //aのサイコロの配列を保持
    int x1, y1, z1;
    int x2, y2, z2;

    x1 = asp[0] + asp[2] + asp[3] + asp[5];
    y1 = asp[0] + asp[1] + asp[4] + asp[5];
    z1 = asp[1] + asp[2] + asp[3] + asp[4];

    x2 = j[0] + j[2] + j[3] + j[5];
    y2 = j[0] + j[1] + j[4] + j[5];
    z2 = j[1] + j[2] + j[3] + j[4];

    if( x1 == x2 && y1 == y2 && z1 == z2 )
        flag == true;
    else
        flag == false;

    return flag;
} 

int main()
{
    int d[6];

    int a, b;
    dice dice1, dice2;

    for( int i = 0; i < 6; i++ )        //入力１
        cin >> d[i];
    
    dice1.setdice( d );                 //dice1セット

    for( int i = 0; i < 6; i++ )        //入力2
        cin >> d[i];

    dice2.setdice( d );                 //dice2セット

    if( dice2.judge( dice1 ) )          //サイコロの一致判定
        cout << "Yes" << endl;
    else
        cout << "No" << endl;


    return 0;
}


Measured memory_bytes: 3168