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

typedef struct
{
        int top;
        int south_side;
        int east_side;
        int west_side;
        int north_side;
        int bottom;
} Dice;

Dice operation_right_rotation_from_topside( Dice dice_tmp )
{
        int tmp = dice_tmp.south_side;
        dice_tmp.south_side = dice_tmp.east_side;
        dice_tmp.east_side = dice_tmp.north_side;
        dice_tmp.north_side = dice_tmp.west_side;
        dice_tmp.west_side = tmp;
        return dice_tmp;
}

Dice change_top_to_northside( Dice dice_tmp )
{
        int tmp = dice_tmp.top;
        dice_tmp.top = dice_tmp.north_side;
        dice_tmp.north_side = dice_tmp.bottom;
        dice_tmp.bottom =  dice_tmp.south_side;
        dice_tmp.south_side = tmp;
        return dice_tmp;
}

Dice change_top_to_southside( Dice dice_tmp )
{
        int tmp = dice_tmp.top;
        dice_tmp.top = dice_tmp.south_side;
        dice_tmp.south_side = dice_tmp.bottom;
        dice_tmp.bottom = dice_tmp.north_side;
        dice_tmp.north_side = tmp;
        return dice_tmp;
}

Dice change_top_to_westside( Dice dice_tmp )
{
        int tmp = dice_tmp.top;
        dice_tmp.top = dice_tmp.west_side;
        dice_tmp.west_side = dice_tmp.bottom;
        dice_tmp.bottom = dice_tmp.east_side;
        dice_tmp.east_side = tmp;
        return dice_tmp;
}

Dice change_top_to_eastside( Dice dice_tmp )
{
        int tmp = dice_tmp.top;
        dice_tmp.top = dice_tmp.east_side;
        dice_tmp.east_side = dice_tmp.bottom;
        dice_tmp.bottom = dice_tmp.west_side;
        dice_tmp.west_side = tmp;
        return dice_tmp;
}

Dice change_top_to_bottom( Dice dice_tmp )
{
        int tmp = dice_tmp.top;
        dice_tmp.top = dice_tmp.bottom;
        dice_tmp.bottom = tmp;

        tmp = dice_tmp.west_side;
        dice_tmp.west_side = dice_tmp.east_side;
        dice_tmp.east_side = tmp;
        return dice_tmp;
}

int compare( Dice dice, Dice dice1 )
{
        if (
                        ( dice.top == dice1.top ) && ( dice.bottom == dice1.bottom ) &&
                        ( dice.north_side == dice1.north_side ) && ( dice.south_side == dice1.south_side) &&
                        ( dice.west_side == dice1.west_side ) && ( dice.east_side == dice1.east_side )
                )
        {
                return 1;
        }

        return 0;
}
int main()
{
        Dice dice, dice1, tmp;
        int eq_flag = 0, count = 0, change_count = 0;

        scanf("%d %d %d %d %d %d", &dice.top, &dice.south_side,
                        &dice.east_side, &dice.west_side, &dice.north_side, &dice.bottom);


        scanf("%d %d %d %d %d %d", &dice1.top, &dice1.south_side,
                        &dice1.east_side, &dice1.west_side, &dice1.north_side, &dice1.bottom);
        tmp = dice1;
        while ( change_count < 6 )
        {

                if ( change_count == 1 )
                {
                        tmp = change_top_to_bottom( dice1 );
                }
                else if ( change_count == 2 )
                {
                        tmp = change_top_to_northside( dice1 );
                }
                else if ( change_count == 3 )
                {
                        tmp = change_top_to_southside( dice1 );
                }
                else if ( change_count == 4 )
                {
                        tmp = change_top_to_westside( dice1 );
                }
                else if ( change_count == 5 )
                {
                        tmp = change_top_to_eastside( dice1 );
                }

                while ( count < 4 )
                {
/*
                        printf("-------------------------------------------------------\n");
                        printf(" dice  %d %d %d %d %d %d\n", dice.top, dice.south_side,
                                        dice.east_side, dice.west_side, dice.north_side, dice.bottom);


                        printf(" dice1 %d %d %d %d %d %d\n", dice1.top, dice1.south_side,
                                        dice1.east_side, dice1.west_side, dice1.north_side, dice1.bottom);

                        printf(" tmp   %d %d %d %d %d %d\n", tmp.top, tmp.south_side,
                                        tmp.east_side, tmp.west_side, tmp.north_side, tmp.bottom);
*/


                        if ( compare( dice, tmp ) == 1 )
                        {
                                eq_flag = 1;
                                break;
                        }
                        tmp = operation_right_rotation_from_topside( tmp );
                        count = count + 1;
                }
                if ( eq_flag == 1 ) break;
                count = 0;
                change_count = change_count + 1;
        }

        if ( eq_flag == 1 )
        {
                printf("Yes\n");
        }
        else
        {
                printf("No\n");
        }

        return 0;
}

Measured memory_bytes: 580