#include <iostream>
#include <cstring>
#include <vector>

using std::vector;

class Dice
{
public:
    Dice();
    void AssignPips();
    int  GetTopPip() { return pip[0]; };
    void Roll(char dir);
    void ShowAllPip();
    int  GetRight(int top, int front);
    int  GetPip(int i) {return pip[i]; };

private:
    int pip[6];
};

int main()
{
    Dice d1;
    Dice d2;
    d1.AssignPips();
    d2.AssignPips();
    std::string dirs = "RRRRNRRRRWRRRRWRRRRWRRRRNRRRR";
    for(int i = 0; i < dirs.length();i++)
    {
        d1.Roll(dirs[i]);
        //std::cout<<dirs[i]<<std::endl;
        //d1.ShowAllPip();
        if(d1.GetPip(0)==d2.GetPip(0)&&
           d1.GetPip(1)==d2.GetPip(1)&&
           d1.GetPip(2)==d2.GetPip(2)&&
           d1.GetPip(3)==d2.GetPip(3)&&
           d1.GetPip(4)==d2.GetPip(4)&&
           d1.GetPip(5)==d2.GetPip(5))
        {
        std::cout<<"Yes"<<std::endl;
        return 0;
        }
    }
    std::cout<<"No"<<std::endl;
    return 0;
}

Dice::Dice() : pip{}
{
}

void Dice::AssignPips()
{
    for(int i = 0; i < 6; i++)
    {
        std::cin>>pip[i];
    }
}

void Dice::Roll(char dir)
{
    int hoge;
    if(dir == 'N')
    {
        hoge   = pip[0];
        pip[0] = pip[1];
        pip[1] = pip[5];
        pip[5] = pip[4];
        pip[4] = hoge;
    }else if(dir == 'S')
    {
        hoge   = pip[1];
        pip[1] = pip[0];
        pip[0] = pip[4];
        pip[4] = pip[5];
        pip[5] = hoge;
    }else if(dir == 'W')
    {
        hoge = pip[0];
        pip[0] = pip[2];
        pip[2] = pip[5];
        pip[5] = pip[3];
        pip[3] = hoge;
    }else if(dir == 'E')
    {
        hoge = pip[2];
        pip[2] = pip[0];
        pip[0] = pip[3];
        pip[3] = pip[5];
        pip[5] = hoge;
    }else
    {
        hoge = pip[1];
        pip[1] = pip[2];
        pip[2] = pip[4];
        pip[4] = pip[3];
        pip[3] = hoge;

    }
}

void Dice::ShowAllPip()
{
    for(int i = 0; i < 6; i++)
    {
        std::cout<<i+1<<": "<<pip[i]<<std::endl;
    }
}

int Dice::GetRight(int top, int front)
{
    //これはもう脳みそがない人のやり方
    if(top==pip[0]&&front==pip[1]) return pip[2];
    else if(top==pip[0]&&front==pip[2])return pip[4];
    else if(top==pip[0]&&front==pip[3])return pip[1];
    else if(top==pip[0]&&front==pip[4])return pip[3];
    else if(top==pip[1]&&front==pip[0])return pip[3];
    else if(top==pip[1]&&front==pip[2])return pip[0];
    else if(top==pip[1]&&front==pip[3])return pip[5];
    else if(top==pip[1]&&front==pip[5])return pip[2];
    else if(top==pip[2]&&front==pip[0])return pip[1];
    else if(top==pip[2]&&front==pip[1])return pip[5];
    else if(top==pip[2]&&front==pip[4])return pip[0];
    else if(top==pip[2]&&front==pip[5])return pip[4];
    else if(top==pip[3]&&front==pip[0])return pip[4];
    else if(top==pip[3]&&front==pip[1])return pip[0];
    else if(top==pip[3]&&front==pip[4])return pip[5];
    else if(top==pip[3]&&front==pip[5])return pip[1];
    else if(top==pip[4]&&front==pip[0])return pip[2];
    else if(top==pip[4]&&front==pip[2])return pip[5];
    else if(top==pip[4]&&front==pip[3])return pip[0];
    else if(top==pip[4]&&front==pip[5])return pip[3];
    else if(top==pip[5]&&front==pip[1])return pip[3];
    else if(top==pip[5]&&front==pip[2])return pip[1];
    else if(top==pip[5]&&front==pip[3])return pip[4];
    else if(top==pip[5]&&front==pip[4])return pip[2];
}



Measured memory_bytes: 3204