#include <bits/stdc++.h>
using namespace std;
int main(){
  vector<int> F1(6);
  for (int i = 0; i < 6; i++){
    cin >> F1[i];
  }
  vector<int> F2(6);
  for (int i = 0; i < 6; i++){
    cin >> F2[i];
  }
  vector<int> F3(6), F4(6);
  for (int i = 0; i < 6; i++){
    F3[i] = F1[i];
    F4[i] = F2[i];
  }
  sort(F3.begin(), F3.end());
  sort(F4.begin(), F4.end());
  bool res = true;
  for (int i = 0; i < 6; i++){
    if (F3[i] != F4[i]){
      res = false;
    }
  }
  if (!res){
    cout << "No" << endl;
  } else {
    res = false;
    if (F1[0] == F2[0] && F1[1] == F2[1] && F1[2] == F2[2] && F1[3] == F2[3] && F1[4] == F2[4] && F1[5] == F2[5]) res = true; //012345
    if (F1[0] == F2[0] && F1[1] == F2[2] && F1[2] == F2[4] && F1[3] == F2[1] && F1[4] == F2[3] && F1[5] == F2[5]) res = true; //024135
    if (F1[0] == F2[0] && F1[1] == F2[3] && F1[2] == F2[1] && F1[3] == F2[4] && F1[4] == F2[2] && F1[5] == F2[5]) res = true; //031425
    if (F1[0] == F2[0] && F1[1] == F2[4] && F1[2] == F2[3] && F1[3] == F2[2] && F1[4] == F2[1] && F1[5] == F2[5]) res = true; //043215
    if (F1[0] == F2[1] && F1[1] == F2[0] && F1[2] == F2[3] && F1[3] == F2[2] && F1[4] == F2[5] && F1[5] == F2[4]) res = true; //103254
    if (F1[0] == F2[1] && F1[1] == F2[2] && F1[2] == F2[0] && F1[3] == F2[5] && F1[4] == F2[3] && F1[5] == F2[4]) res = true; //120534
    if (F1[0] == F2[1] && F1[1] == F2[3] && F1[2] == F2[5] && F1[3] == F2[0] && F1[4] == F2[2] && F1[5] == F2[4]) res = true; //135024
    if (F1[0] == F2[1] && F1[1] == F2[5] && F1[2] == F2[2] && F1[3] == F2[3] && F1[4] == F2[0] && F1[5] == F2[4]) res = true; //152304
    if (F1[0] == F2[2] && F1[1] == F2[0] && F1[2] == F2[1] && F1[3] == F2[4] && F1[4] == F2[5] && F1[5] == F2[3]) res = true; //201453
    if (F1[0] == F2[2] && F1[1] == F2[1] && F1[2] == F2[5] && F1[3] == F2[0] && F1[4] == F2[4] && F1[5] == F2[3]) res = true; //215043
    if (F1[0] == F2[2] && F1[1] == F2[4] && F1[2] == F2[0] && F1[3] == F2[5] && F1[4] == F2[1] && F1[5] == F2[3]) res = true; //240513
    if (F1[0] == F2[2] && F1[1] == F2[5] && F1[2] == F2[4] && F1[3] == F2[1] && F1[4] == F2[0] && F1[5] == F2[3]) res = true; //254103
    if (F1[0] == F2[3] && F1[1] == F2[0] && F1[2] == F2[4] && F1[3] == F2[1] && F1[4] == F2[5] && F1[5] == F2[2]) res = true; //304152
    if (F1[0] == F2[3] && F1[1] == F2[1] && F1[2] == F2[0] && F1[3] == F2[5] && F1[4] == F2[4] && F1[5] == F2[2]) res = true; //310542
    if (F1[0] == F2[3] && F1[1] == F2[4] && F1[2] == F2[5] && F1[3] == F2[0] && F1[4] == F2[1] && F1[5] == F2[2]) res = true; //345012
    if (F1[0] == F2[3] && F1[1] == F2[5] && F1[2] == F2[1] && F1[3] == F2[4] && F1[4] == F2[0] && F1[5] == F2[2]) res = true; //351402
    if (F1[0] == F2[4] && F1[1] == F2[0] && F1[2] == F2[2] && F1[3] == F2[3] && F1[4] == F2[5] && F1[5] == F2[1]) res = true; //402351
    if (F1[0] == F2[4] && F1[1] == F2[2] && F1[2] == F2[5] && F1[3] == F2[0] && F1[4] == F2[3] && F1[5] == F2[1]) res = true; //425031
    if (F1[0] == F2[4] && F1[1] == F2[3] && F1[2] == F2[0] && F1[3] == F2[5] && F1[4] == F2[2] && F1[5] == F2[1]) res = true; //430521
    if (F1[0] == F2[4] && F1[1] == F2[5] && F1[2] == F2[3] && F1[3] == F2[2] && F1[4] == F2[0] && F1[5] == F2[1]) res = true; //453201
    if (F1[0] == F2[5] && F1[1] == F2[1] && F1[2] == F2[3] && F1[3] == F2[2] && F1[4] == F2[4] && F1[5] == F2[0]) res = true; //513240
    if (F1[0] == F2[5] && F1[1] == F2[2] && F1[2] == F2[1] && F1[3] == F2[4] && F1[4] == F2[3] && F1[5] == F2[0]) res = true; //521430
    if (F1[0] == F2[5] && F1[1] == F2[3] && F1[2] == F2[4] && F1[3] == F2[1] && F1[4] == F2[2] && F1[5] == F2[0]) res = true; //534120
    if (F1[0] == F2[5] && F1[1] == F2[4] && F1[2] == F2[2] && F1[3] == F2[3] && F1[4] == F2[1] && F1[5] == F2[0]) res = true; //542310
    if (res){
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
}


Measured memory_bytes: 3164