class Dice:

    same_dice_index = ((0, 1, 2, 3, 4, 5), (0, 2, 4, 1, 3, 5), (0, 3, 1, 4, 2, 5),

                       (0, 4, 3, 2, 1, 5), (1, 0, 3, 2, 5, 4), (1, 2, 0, 5, 3, 4),

                       (1, 3, 5, 0, 2, 4), (1, 5, 2, 3, 0, 4), (2, 0, 1, 4, 5, 3),

                       (2, 1, 5, 0, 4, 3), (2, 4, 0, 5, 1, 3), (2, 5, 4, 1, 0, 3),

                       (3, 0, 4, 1, 5, 2), (3, 1, 0, 5, 4, 2), (3, 4, 5, 0, 1, 2),

                       (3, 5, 1, 4, 0, 2), (4, 0, 2, 3, 5, 1), (4, 2, 5, 0, 3, 1),

                       (4, 3, 0, 5, 2, 1), (4, 5, 3, 2, 0, 1), (5, 1, 3, 2, 4, 0),

                       (5, 2, 1, 4, 3, 0), (5, 3, 4, 1, 2, 0), (5, 4, 2, 3, 1, 0))



    def __init__(self, str_tpl):

        self.faces = str_tpl



    def is_same(self, dice):

        for i in Dice.same_dice_index:

            for n, j in enumerate(i):

                if dice.faces[n] != self.faces[j]:

                    break

            else:

                return True

        return False





str_tpl1 = tuple(input().split())

dice1 = Dice(str_tpl1)



str_tpl2 = tuple(input().split())

dice2 = Dice(str_tpl2)



if dice1.is_same(dice2):

    print('Yes')

else:

    print('No')
class Dice:

    same_dice_index = ((0, 1, 2, 3, 4, 5), (0, 2, 4, 1, 3, 5), (0, 3, 1, 4, 2, 5),

                       (0, 4, 3, 2, 1, 5), (1, 0, 3, 2, 5, 4), (1, 2, 0, 5, 3, 4),

                       (1, 3, 5, 0, 2, 4), (1, 5, 2, 3, 0, 4), (2, 0, 1, 4, 5, 3),

                       (2, 1, 5, 0, 4, 3), (2, 4, 0, 5, 1, 3), (2, 5, 4, 1, 0, 3),

                       (3, 0, 4, 1, 5, 2), (3, 1, 0, 5, 4, 2), (3, 4, 5, 0, 1, 2),

                       (3, 5, 1, 4, 0, 2), (4, 0, 2, 3, 5, 1), (4, 2, 5, 0, 3, 1),

                       (4, 3, 0, 5, 2, 1), (4, 5, 3, 2, 0, 1), (5, 1, 3, 2, 4, 0),

                       (5, 2, 1, 4, 3, 0), (5, 3, 4, 1, 2, 0), (5, 4, 2, 3, 1, 0))



    def __init__(self, str_tpl):

        self.faces = str_tpl



    def is_same(self, dice):

        for i in Dice.same_dice_index:

            for n, j in enumerate(i):

                if dice.faces[n] != self.faces[j]:

                    break

            else:

                return 'Yes'

        return 'No'





str_tpl1 = tuple(input().split())

dice1 = Dice(str_tpl1)



str_tpl2 = tuple(input().split())

dice2 = Dice(str_tpl2)



print((dice1.is_same(dice2)))
class Dice:
    same_dice_index = (
        (0, 1, 2, 3, 4, 5),
        (0, 2, 4, 1, 3, 5),
        (0, 3, 1, 4, 2, 5),
        (0, 4, 3, 2, 1, 5),
        (1, 0, 3, 2, 5, 4),
        (1, 2, 0, 5, 3, 4),
        (1, 3, 5, 0, 2, 4),
        (1, 5, 2, 3, 0, 4),
        (2, 0, 1, 4, 5, 3),
        (2, 1, 5, 0, 4, 3),
        (2, 4, 0, 5, 1, 3),
        (2, 5, 4, 1, 0, 3),
        (3, 0, 4, 1, 5, 2),
        (3, 1, 0, 5, 4, 2),
        (3, 4, 5, 0, 1, 2),
        (3, 5, 1, 4, 0, 2),
        (4, 0, 2, 3, 5, 1),
        (4, 2, 5, 0, 3, 1),
        (4, 3, 0, 5, 2, 1),
        (4, 5, 3, 2, 0, 1),
        (5, 1, 3, 2, 4, 0),
        (5, 2, 1, 4, 3, 0),
        (5, 3, 4, 1, 2, 0),
        (5, 4, 2, 3, 1, 0),
    )

    def __init__(self, str_tpl):
        self.faces = str_tpl

    def is_same(self, dice):
        for i in Dice.same_dice_index:
            for n, j in enumerate(i):
                if dice.faces[n] != self.faces[j]:
                    break
            else:
                return True
        return False


str_tpl1 = tuple(input().split())
dice1 = Dice(str_tpl1)
str_tpl2 = tuple(input().split())
dice2 = Dice(str_tpl2)
if dice1.is_same(dice2):
    print("Yes")
else:
    print("No")

class Dice:
    same_dice_index = (
        (0, 1, 2, 3, 4, 5),
        (0, 2, 4, 1, 3, 5),
        (0, 3, 1, 4, 2, 5),
        (0, 4, 3, 2, 1, 5),
        (1, 0, 3, 2, 5, 4),
        (1, 2, 0, 5, 3, 4),
        (1, 3, 5, 0, 2, 4),
        (1, 5, 2, 3, 0, 4),
        (2, 0, 1, 4, 5, 3),
        (2, 1, 5, 0, 4, 3),
        (2, 4, 0, 5, 1, 3),
        (2, 5, 4, 1, 0, 3),
        (3, 0, 4, 1, 5, 2),
        (3, 1, 0, 5, 4, 2),
        (3, 4, 5, 0, 1, 2),
        (3, 5, 1, 4, 0, 2),
        (4, 0, 2, 3, 5, 1),
        (4, 2, 5, 0, 3, 1),
        (4, 3, 0, 5, 2, 1),
        (4, 5, 3, 2, 0, 1),
        (5, 1, 3, 2, 4, 0),
        (5, 2, 1, 4, 3, 0),
        (5, 3, 4, 1, 2, 0),
        (5, 4, 2, 3, 1, 0),
    )

    def __init__(self, str_tpl):
        self.faces = str_tpl

    def is_same(self, dice):
        for i in Dice.same_dice_index:
            for n, j in enumerate(i):
                if dice.faces[n] != self.faces[j]:
                    break
            else:
                return "Yes"
        return "No"


str_tpl1 = tuple(input().split())
dice1 = Dice(str_tpl1)
str_tpl2 = tuple(input().split())
dice2 = Dice(str_tpl2)
print((dice1.is_same(dice2)))

-                return True -        return False +                return "Yes" +        return "No" -if dice1.is_same(dice2): -    print("Yes") -else: -    print("No") +print((dice1.is_same(dice2)))