class Dice():
    def __init__(self):
        self.num = [0 for _ in range(6)]
    
    def set_num(self, n0, n1, n2, n3, n4, n5):
        self.num[0] = n0
        self.num[1] = n1
        self.num[2] = n2
        self.num[3] = n3
        self.num[4] = n4
        self.num[5] = n5
    
    
    def roll(self, order):
        tmp = self.num.copy()
        
        if order == "N":
            self.set_num(tmp[1], tmp[5], tmp[2], tmp[3], tmp[0], tmp[4])
        elif order == "S":
            self.set_num(tmp[4], tmp[0], tmp[2], tmp[3], tmp[5], tmp[1])
        elif order == "E":
            self.set_num(tmp[3], tmp[1], tmp[0], tmp[5], tmp[4], tmp[2])
        elif order == "W":
            self.set_num(tmp[2], tmp[1], tmp[5], tmp[0], tmp[4], tmp[3])
        elif order == "rot_Clock":
            self.set_num(tmp[0], tmp[2], tmp[4], tmp[1], tmp[3], tmp[5])
        else:
            print("Error: 不正な入力です")

    def get_top_num(self):
        return self.num[0]
        
    
# Input
init_num1 = [int(_) for _ in input().split()]
init_num2 = [int(_) for _ in input().split()]

# Set Dice
dice1 = Dice()
dice2 = Dice()
dice1.set_num(init_num1[0], init_num1[1], init_num1[2], init_num1[3], init_num1[4], init_num1[5])
dice2.set_num(init_num2[0], init_num2[1], init_num2[2], init_num2[3], init_num2[4], init_num2[5])

# 1st way
checker = False
for i in range(3):
    for j in range(3):
        orders = "N" * (i + 1) + "E" * (j + 1)
        # print(orders)
        
        for order in orders:
            dice2.roll(order)
        if dice1.num == dice2.num:
            checker = True
        
for i in range(3):
    for j in range(3):
        orders = "E" * (i + 1) + "N" * (j + 1)
        # print(orders)
        
        for order in orders:
            dice2.roll(order)
        if dice1.num == dice2.num:
            checker = True

for i in range(3):
    for j in range(3):
        for k in range(3):
            orders = "E" * (i + 1) + "N" * (j + 1) + "E" * (k + 1)
            # print(orders)
            
            for order in orders:
                dice2.roll(order)
            if dice1.num == dice2.num:
                checker = True

for i in range(3):
    for j in range(3):
        for k in range(3):
            orders = "N" * (i + 1) + "E" * (j + 1) + "N" * (k + 1)
            # print(orders)
            
            for order in orders:
                dice2.roll(order)
            if dice1.num == dice2.num:
                checker = True


# 2nd way
if checker == False:
    num_dice1_top, num_dice1_front = dice1.num[0], dice1.num[1]
    
    index_top = dice2.num.index(num_dice1_top)
    index_front = dice2.num.index(num_dice1_front)
    
    counter = 0
    while (index_top != 0) & (counter < 3):
        counter += 1
        if index_top in [0, 1, 4, 5]:
            dice2.roll("N")
            index_top = dice2.num.index(num_dice1_top)
            index_front = dice2.num.index(num_dice1_front)
        else:
            dice2.roll("E")
            index_top = dice2.num.index(num_dice1_top)
            index_front = dice2.num.index(num_dice1_front)
    
    counter = 0
    while (index_front != 1) & (counter < 3):
            dice2.roll("rot_Clock")
            index_top = dice2.num.index(num_dice1_top)
            index_front = dice2.num.index(num_dice1_front)
    
    # print(f"dice1: {dice1.num}")
    # print(f"dice2: {dice2.num}")
    
    if dice1.num == dice2.num:
        checker = True

if checker:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 5740