#include <stdio.h>
#include <string.h>

//Structure definition-----------------------------------------------------------------------------------------
typedef struct{
  int top;
  int front;
  int right;
  int left;
  int back;
  int under;
} DICE;

//Macro--------------------------------------------------------------------------------------------------------
#define TOP   Dice.top
#define FRONT Dice.front
#define RIGHT Dice.right
#define LEFT  Dice.left
#define BACK  Dice.back
#define UNDER Dice.under

//Prototype-----------------------------------------------------------------------------------------------------
int main(void);
int dice_check(DICE, int, int, int, int, int, int, int, int);
DICE R_rotation(DICE);
DICE dice_rotation(DICE, char*);
DICE direction_change(char*, DICE);

//main()---------------------------------------------------------------------------------------------------------
int main(void){
    DICE Dice1;
    DICE Dice2;
    char* move_ad;
    int count = 1;
    int flag  = 1;

    scanf("%d %d %d %d %d %d", &Dice1.top, &Dice1.front, &Dice1.right, &Dice1.left, &Dice1.back, &Dice1.under);
    scanf("%d %d %d %d %d %d", &Dice2.top, &Dice2.front, &Dice2.right, &Dice2.left, &Dice2.back, &Dice2.under);

    //Dice rotation
    while (count <= 6)
    {
        switch (count){
            case 2:
            case 3:
            case 4:
                Dice2 = R_rotation(Dice2);
                break;
            case 5:
                Dice2 = R_rotation(Dice2);
                move_ad = "N\0";
                Dice2 = dice_rotation(Dice2, move_ad);
                break;
            case 6:
                move_ad = "NN\0";
                Dice2 = dice_rotation(Dice2, move_ad);
                break;
            default:
                break;
        }

        flag = dice_check(Dice2, Dice1.top, Dice1.front, Dice1.right, Dice1.left, Dice1.back, Dice1.under, count, flag);

        if (!flag){
            printf("Yes\n");
            break;
        }
        else if(flag & count == 6){
            printf("No\n");
        }
        count++;
    }

    return 0;
}


//dice_check()----------------------------------------------------------------------------------------------------------
int dice_check(DICE Dice, int T, int F, int R, int L, int B, int U, int ct, int _flag)
{
    for (int i = 0; i < 4; i++)
    {
        if(T == TOP & F == FRONT & R == RIGHT & L == LEFT & B == BACK & U == UNDER){
            _flag = 0;
            break;
        }
        Dice = dice_rotation(Dice, "W\0");
    }

    return _flag;
}


//L_rotation()--------------------------------------------------------------------------------------------------------
DICE R_rotation(DICE Dice)
{
    int hold = FRONT;
    FRONT = RIGHT;
    RIGHT = BACK;
    BACK = LEFT;
    LEFT = hold;

    return Dice;
}

//dice_rotation()-----------------------------------------------------------------------------------------------------
DICE dice_rotation(DICE Dice, char* m_ad)
{
    char direction[3] = {};
    strcpy(direction, m_ad);

    for (int i = 0; i < strlen(direction); i++) {
        Dice = direction_change(&direction[i], Dice);
    }
    return Dice;
}


//direction_change()--------------------------------------------------------------------------------------------------
DICE direction_change(char* judge, DICE Dice){
  int hold = 0;
  switch (*judge) {
    case 'N':
      hold = UNDER;
      UNDER = BACK;
      BACK = TOP;
      TOP = FRONT;
      FRONT = hold;
    break;
    case 'E':
      hold = UNDER;
      UNDER = RIGHT;
      RIGHT= TOP;
      TOP = LEFT;
      LEFT = hold;
    break;
    case 'S':
      hold = UNDER;
      UNDER = FRONT;
      FRONT = TOP;
      TOP = BACK;
      BACK = hold;
    break;
    case 'W':
    hold = UNDER;
    UNDER = LEFT;
    LEFT= TOP;
    TOP = RIGHT;
    RIGHT = hold;
    break;
  }
  return Dice;
}


Measured memory_bytes: 2132