#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   

using namespace std;
#define i64  long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807

  vector<int> roll(char opp,vector<int>  DICE)
  {
    vector<int> rolled(6,0);

    if(opp =='W')
    {
      rolled[0] = DICE[2];
      rolled[1] = DICE[1];
      rolled[2] = DICE[5];
      rolled[3] = DICE[0];
      rolled[4] = DICE[4];
      rolled[5] = DICE[3];
    }
    else if( opp == 'S')
    {
      rolled[0] = DICE[4];
      rolled[1] = DICE[0];
      rolled[2] = DICE[2];
      rolled[3] = DICE[3];
      rolled[4] = DICE[5];
      rolled[5] = DICE[1];
    }
    else if(opp == 'N')
    {
      rolled[0] = DICE[1];
      rolled[1] = DICE[5];
      rolled[2] = DICE[2];
      rolled[3] = DICE[3];
      rolled[4] = DICE[0];
      rolled[5] = DICE[4];
    }

    else if(opp == 'E')
    {
      rolled[0] = DICE[3];
      rolled[1] = DICE[1];
      rolled[2] = DICE[0];
      rolled[3] = DICE[5];
      rolled[4] = DICE[4];
      rolled[5] = DICE[2];
    }
    else if(opp == 'R')
    {
      rolled[0] = DICE[0];
      rolled[1] = DICE[2];
      rolled[2] = DICE[4];
      rolled[3] = DICE[1];
      rolled[4] = DICE[3];
      rolled[5] = DICE[5];     
    }
    else
    {
      cout<<"XXX"<<endl;
    }
    

    return rolled;
    

  }

  bool Q_check(vector<int> DICE,int TOP,int FRONT)
  {
    if((DICE[0] == TOP)&&(DICE[1] ==FRONT))
    {
      cout<<DICE[2]<<endl;
      return 1;
    }

    return 0;
  }

  bool Q_check_2(vector<int> DICE,vector<int> DICE_2)
  {
    bool check = 1;

    for (int i = 0; i < 6; i++)
    {
      if(DICE[i] != DICE_2[i]) check = 0;
    }

    if(check == 1)
    {
      cout<<"Yes"<<endl;
      return 1;
    }
    

    return 0;
  }


  void Q(vector<int> DICE,int TOP,int FRONT)
  {
    bool check = 0;

    for (int q = 0; q < 4; q++)
    {
     for (int i = 0; i < 4; i++)
    {
      DICE = roll('R',DICE);
      check = Q_check(DICE,TOP,FRONT);
      if(check == 1) return;
    }

    DICE = roll('N',DICE);     
    }
    
    for (int q = 0; q < 4; q++)
    {
     for (int i = 0; i < 4; i++)
    {
      DICE = roll('R',DICE);
      check = Q_check(DICE,TOP,FRONT);
      if(check == 1) return;
    }

    DICE = roll('E',DICE);     
    }

  
  }

  void DICE_COMP(vector<int> DICE, vector<int> DICE_2)
  {
    bool check = 0;

    for (int q = 0; q < 4; q++)
    {
     for (int i = 0; i < 4; i++)
    {
      DICE = roll('R',DICE);
      check = Q_check_2(DICE,DICE_2);
      if(check == 1) return;
    }

    DICE = roll('N',DICE);     
    }
    
    for (int q = 0; q < 4; q++)
    {
     for (int i = 0; i < 4; i++)
    {
      DICE = roll('R',DICE);
      check = Q_check_2(DICE,DICE_2);
      if(check == 1) return;
    }

    DICE = roll('E',DICE);     
    }

    cout<<"No"<<endl;
    return;
  }
void solve(void)
{ 

  vector<int> DICE (6,0);

  vector<int> DICE_2(6,0);
  for (int i = 0; i < 6; i++)
  {
    cin>>DICE[i];
  }

  for (int i = 0; i < 6; i++)
  {
    cin>>DICE_2[i];
  }

  DICE_COMP(DICE,DICE_2);


  return;
}

int main(int argc, const char *argv[])
{

  solve();

  return 0;
}



Measured memory_bytes: 3152