Problem:
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});

Dice III

Write a program which reads the two dices constructed in the same way as Dice I, and determines whether these two dices are identical. You can roll a dice in the same way as Dice I, and if all integers observed from the six directions are the same as that of another dice, these dices can be considered as identical.

Input

In the first line, six integers assigned to faces of a dice are given in ascending order of their corresponding labels.

In the second line, six integers assigned to faces of another dice are given in ascending order of their corresponding labels.

Output

Print "Yes" if two dices are identical, otherwise "No" in a line.

Constraints

$0 \leq $ the integer assigned to a face $ \leq 100$

Sample Input 1

1 2 3 4 5 6
6 2 4 3 5 1

Sample Output 1

Yes

Sample Input 2

1 2 3 4 5 6
6 5 4 3 2 1

Sample Output 2

No

Solution in Python3 (judge verdict: Wrong Answer)

class Dice:
    def __init__(self):
        self.state =[1, 2, 3, 4, 5, 6]

    def setState(self, li):  # [top, S, E, W, N, under]
        self.state = li

    def move(self, str_direction):
        if str_direction == "N":
            self.state = [self.state[1], self.state[5],self.state[2],
                          self.state[3], self.state[0], self.state[4]]
        if str_direction == "W":
            self.state = [self.state[2], self.state[1], self.state[5],
                          self.state[0], self.state[4], self.state[3]]
        if str_direction == "E":
            self.state = [self.state[3], self.state[1], self.state[0],
                          self.state[5], self.state[4], self.state[2]]
        if str_direction == "S":
            self.state = [self.state[4], self.state[0], self.state[2],
                          self.state[3], self.state[5], self.state[1]]

    def rotate(self):
        self.state = [self.state[0], self.state[2], self.state[1],
                      self.state[4], self.state[3], self.state[5]]

    def sameDice0(self, dice1):
        for i in self.state:
            if i not in dice1.state:
                return "No"
        count = 0
        while True:
            if self.state[0] == dice1.state[0]:
                break
            if count % 3 == 0:
                self.move("W")
            else:
                self.move("N")
        for _ in range(3):
            if self.state[1] == dice1.state[1]:
                break
            self.rotate()
        if self.state != dice1.state:
            return "No"
        return "Yes"

    def sameDice1(self, dice1):
        set1 = list()
        for _ in range(5):
            set1.append([self.state[0], self.state[1], self.state[2]])
            set1.append([self.state[4], self.state[5], self.state[3]])
            self.move("N")
        print(set1)
        d1 = [dice1.state[0], dice1.state[1], dice1.state[2]]
        d2 = [dice1.state[4], dice1.state[5], dice1.state[3]]
        if d1 in set1 or d2 in set1:
            return "Yes"
        return self.sameDice0(dice1)






def main():
    myd1, myd2 = Dice(), Dice()
    myd1.setState(list(map(int, input().split())))
    myd2.setState(list(map(int, input().split())))
    print(myd1.sameDice1(myd2))
    return


if __name__ == "__main__":
    main()