class Dice:
    def __init__(self, numbers):
        self.dice = {"上" :numbers[0],
                     "下":numbers[5], 
                     "前":numbers[1],
                     "後":numbers[4],
                     "左":numbers[3],
                     "右":numbers[2]
                    }
    
    def order(self, order_seq):
        for _, order in enumerate(order_seq):
            if order == "N":
                self.north()
            elif order == "E":
                self.east()
            elif order == "W":
                self.west()
            elif order == "S":
                self.south()
        
        return self.dice["上"]

    def north(self):
        U, D, F, B = [self.dice["上"], self.dice["下"], self.dice["前"], self.dice["後"]]
        self.dice["上"] = F
        self.dice["前"] = D
        self.dice["下"] = B
        self.dice["後"] = U

    def east(self):
        U, D, L, R = [self.dice["上"], self.dice["下"], self.dice["左"], self.dice["右"]]
        self.dice["上"] = L
        self.dice["下"] = R
        self.dice["左"] = D
        self.dice["右"] = U

    def west(self):
        U, D, L, R = [self.dice["上"], self.dice["下"], self.dice["左"], self.dice["右"]]
        self.dice["上"] = R
        self.dice["下"] = L
        self.dice["左"] = U
        self.dice["右"] = D

    def south(self):
        U, D, F, B = [self.dice["上"], self.dice["下"], self.dice["前"], self.dice["後"]]
        self.dice["上"] = B
        self.dice["前"] = U
        self.dice["下"] = F
        self.dice["後"] = D   

    def set_position(self, n, position_seq):
        self.ans = []
        for i in range(n):
            self.up = position_seq[i][0]
            self.front = position_seq[i][1]

            self.search()
            self.west()
            self.search()
            self.west()
            self.search()
            self.north()
            self.search()
            self.west()
            self.search()
            self.west()
            self.search()
        
        return self.ans
    
    def search(self):
        # print("goal:上", self.up, ":", self.dice["上"])
        if self.dice["上"] == self.up:
            for _ in range(4):
                # print("goal:前|上 ", self.front, ":", self.dice["前"],
                #      "|", self.dice["上"], "→", self.dice["右"])
                if self.dice["前"] == self.front:
                    self.ans = [self.dice["右"], self.dice["後"], self.dice["左"], self.dice["下"]]
                    break
                self.rotate()
            # self.ans.append(self.dice["右"])

    def rotate(self):
        F, R, B, L = [self.dice["前"], self.dice["右"], self.dice["後"], self.dice["左"]]
        self.dice["前"] = R
        self.dice["右"] = B
        self.dice["後"] = L
        self.dice["左"] = F
        
numbers = list(map(int, input().split()))
dice1 = Dice(numbers)
numbers = list(map(int, input().split()))
dice2 = Dice(numbers)

position_seq = [[dice2.dice["上"], dice2.dice["前"]]]
answer = [dice2.dice["右"], dice2.dice["後"], dice2.dice["左"], dice2.dice["下"]]

ans = dice1.set_position(1, position_seq)

for i in range(4):
    if ans == None or ans[i] != answer[i]:
        print('No')
        break
if i == 3:
    print('Yes')




Measured memory_bytes: 5728