#include <iostream>
#include <stdio.h>
#include <vector>
#include <math.h>
#include <string>
class dice{
private:
    int a,b,c,d,e,f,inas,inbs,ans;
    std::vector <int> list={0,1,2,3,4,5};
    std::vector <int> listb={0,1,2,3,4,5};
    std::vector <int> listc={0,1,2,3,4,5};
public:
    dice(int i,int j,int k,int l,int m,int n){
        a=i;
        b=j;
        c=k;
        d=l;
        e=m;
        f=n;
        listc[0]=a;
        listc[1]=b;
        listc[2]=c;
        listc[3]=d;
        listc[4]=e;
        listc[5]=f;
    }
    void print(){
//        std::cout <<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<" "<< f<<std::endl;
        if(list[0]==0)std::cout<<a<<std::endl;
        if(list[0]==1)std::cout<<b<<std::endl;
        if(list[0]==2)std::cout<<c<<std::endl;
        if(list[0]==3)std::cout<<d<<std::endl;
        if(list[0]==4)std::cout<<e<<std::endl;
        if(list[0]==5)std::cout<<f<<std::endl;
    }
    void rightp(int ina,int inb){
            listc[0]=a;
            listc[1]=b;
            listc[2]=c;
            listc[3]=d;
            listc[4]=e;
            listc[5]=f;
            for(int inf=0;inf<6;inf++){
                if(ina==listc[inf])inas=inf;
                if(inb==listc[inf])inbs=inf;
            }
            //inas,inbs = motono junban(ue nara 0 mae nara 1)
            for(int ing=0;ing<6;ing++){
                listb[ing]=list[ing];
            }

            if(inas==0&&inbs==1)ans=2;
            if(inas==0&&inbs==2)ans=4;
            if(inas==0&&inbs==4)ans=3;
            if(inas==0&&inbs==3)ans=1;

            if(inas==1&&inbs==5)ans=2;
            if(inas==1&&inbs==2)ans=0;
            if(inas==1&&inbs==0)ans=3;
            if(inas==1&&inbs==3)ans=5;

            if(inas==2&&inbs==1)ans=5;
            if(inas==2&&inbs==5)ans=4;
            if(inas==2&&inbs==4)ans=0;
            if(inas==2&&inbs==0)ans=1;

            if(inas==3&&inbs==1)ans=0;
            if(inas==3&&inbs==0)ans=4;
            if(inas==3&&inbs==4)ans=5;
            if(inas==3&&inbs==5)ans=1;

            if(inas==4&&inbs==0)ans=2;
            if(inas==4&&inbs==2)ans=5;
            if(inas==4&&inbs==5)ans=3;
            if(inas==4&&inbs==3)ans=0;

            if(inas==5&&inbs==4)ans=2;
            if(inas==5&&inbs==2)ans=1;
            if(inas==5&&inbs==1)ans=3;
            if(inas==5&&inbs==3)ans=4;

            std::cout << listc[ans] << std::endl;
    }

    void move(int in){
        if(in==0){
           listb[0]=list[3];//W
           listb[2]=list[0];
           listb[3]=list[5];
           listb[5]=list[2];
        }
        if(in==1){
           listb[0]=list[4];//N
           listb[4]=list[5];
           listb[5]=list[1];
           listb[1]=list[0];
        }
        if(in==2){
            listb[0]=list[2];//E
            listb[2]=list[5];
            listb[5]=list[3];
            listb[3]=list[0];
        }
        if(in==3){
            listb[0]=list[1];//S
            listb[1]=list[5];
            listb[5]=list[4];
            listb[4]=list[0];
        }
        for(int ine=0;ine<6;ine++){
            list[ine]=listb[ine];
            //std::cout << list[ine];
        }
    }
    int hen(int n){
        int aga=list[n];
        return listc[aga];
    }

};
bool kensa(int a1,int a2,int a3,int a4,int a5,int a6,int b1,int b2,int b3,int b4,int b5,int b6){
    int gagtg=0;
    int kak;
    std::string teas;
    std::vector <int> nlist={a1,a2,a3,a4,a5,a6};
    dice m(b1,b2,b3,b4,b5,b6);
    std::string nan="222322232221222122232222";
    for(int tat=0;tat<24;tat++){
        for(int tab=0;tab<6;tab++){
            //std::cout << m.hen(tab) << " " << nlist[tab] << std::endl;
            if(m.hen(tab)==nlist[tab])gagtg++;
        }
        if(gagtg>5)return true;
        gagtg=0;
        teas=nan[tat];
        kak=std::stol(teas);
        m.move(kak);//(kak);
    }
    return false;
}

int main()
{
    int a1,a2,a3,a4,a5,a6,b1,b2,b3,b4,b5,b6;
    std::vector <int> nlist={0,0,0,0,0,0};
    std::vector <int> mlist={0,0,0,0,0,0};
    std::cin >>a1>>a2>>a3>>a4>>a5>>a6;
    std::cin >>b1>>b2>>b3>>b4>>b5>>b6;
    /*dice n(a1,a2,a3,a4,a5,a6);
    dice m(b1,b2,b3,b4,b5,b6);*/
    if(kensa(a1,a2,a3,a4,a5,a6,b1,b2,b3,b4,b5,b6)){
        std::cout <<"Yes" << std::endl;
    }else{std::cout <<"No" << std::endl;}

    return 0;
}

Measured memory_bytes: 3184