#include<iostream>
#include<string>

using namespace std;

class Dice{
public:
  int
   originalD[6];
  int realD[6];
  string s;
  void setD(int originalD[],int realD[]);
  void moveD(int realD[],string s,int n);
  void breakmoveD(int realD[],string s,int n,int another[],int *judge);
  void outu(int realD[]);
};

void Dice::setD(int orinalD[],int realD[]){
  for(int i=0;i<6;i++){
    cin>>originalD[i];
    realD[i]=originalD[i];
  }
}

void Dice::moveD(int realD[],string s,int n){
  int aD[6];
  int x;
  for(int i=0;i<n;i++){
    if(s[i]=='N')x=0;
    if(s[i]=='S')x=1;
    if(s[i]=='E')x=2;
    if(s[i]=='W')x=3;
    switch(x){
      case 0:
              aD[0]=realD[1];
              aD[1]=realD[5];
              aD[2]=realD[2];
              aD[3]=realD[3];
              aD[4]=realD[0];
              aD[5]=realD[4];
              break;
      case 1:
              aD[0]=realD[4];
              aD[1]=realD[0];
              aD[2]=realD[2];
              aD[3]=realD[3];
              aD[4]=realD[5];
              aD[5]=realD[1];
              break;
      case 2:
              aD[0]=realD[3];
              aD[1]=realD[1];
              aD[2]=realD[0];
              aD[3]=realD[5];
              aD[4]=realD[4];
              aD[5]=realD[2];
              break;
      case 3:
              aD[0]=realD[2];
              aD[1]=realD[1];
              aD[2]=realD[5];
              aD[3]=realD[0];
              aD[4]=realD[4];
              aD[5]=realD[3];
              break;
      }
      for(int v=0;v<6;v++){
        realD[v]=aD[v];
      }
  }
}

void Dice::breakmoveD(int realD[],string s,int n,int another[],int *judge){
  int f=0;
  if(realD[0]==another[0])f=5;
  int aD[6];
  int x,t;
  if(f==0){
    for(int i=0;i<n;i++){
      if(s[i]=='N')x=0;
      if(s[i]=='S')x=1;
      if(s[i]=='E')x=2;
      if(s[i]=='W')x=3;
      switch(x){
        case 0:
                aD[0]=realD[1];
                aD[1]=realD[5];
                aD[2]=realD[2];
                aD[3]=realD[3];
                aD[4]=realD[0];
                aD[5]=realD[4];
                break;
        case 1:
                aD[0]=realD[4];
                aD[1]=realD[0];
                aD[2]=realD[2];
                aD[3]=realD[3];
                aD[4]=realD[5];
                aD[5]=realD[1];
                break;
        case 2:
                aD[0]=realD[3];
                aD[1]=realD[1];
                aD[2]=realD[0];
                aD[3]=realD[5];
                aD[4]=realD[4];
                aD[5]=realD[2];
                break;
        case 3:
                aD[0]=realD[2];
                aD[1]=realD[1];
                aD[2]=realD[5];
                aD[3]=realD[0];
                aD[4]=realD[4];
                aD[5]=realD[3];
                break;
        }
        for(int v=0;v<6;v++){
          realD[v]=aD[v];
        }
        if(realD[0]==another[0])break;
    }
  }
}

void Dice::outu(int realD[]){
  cout<<realD[0]<<endl;
}

int main(){
  Dice dice1,dice2;
  dice1.setD(dice1.originalD,dice1.realD);
  dice2.setD(dice2.originalD,dice2.realD);
  //move dice2,and compare it with dice1.
  int *judge,t,n=6;
  judge=&t;
  string s="NNNWWW";
  dice2.breakmoveD(dice2.realD,s,n,dice1.realD,judge);
  if(*judge!=-1){
    s="N";
    n=1;
    dice1.moveD(dice1.realD,s,n);
    s="NWWW";
    n=4;
    dice2.breakmoveD(dice2.realD,s,n,dice1.realD,judge);
  }
  if(*judge!=-1&&dice1.realD[1]==dice2.realD[1]&&
    dice1.realD[2]==dice2.realD[2]&&dice1.realD[3]==dice2.realD[3]){
      *judge=10;}else{
      *judge=-1;
    }
  if(*judge==10)cout<<"Yes"<<endl;
  if(*judge==-1)cout<<"No"<<endl;
  return 0;
}



Measured memory_bytes: 3212