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, num_tuple):
        self.faces = num_tuple

    def find_rf(self, top, front):
        tf = str(self.faces.index(top)) + str(self.faces.index(front))
        if tf in '12431':
            return self.faces[0]
        elif tf in '03520':
            return self.faces[1]
        elif tf in '01540':
            return self.faces[2]
        elif tf in '04510':
            return self.faces[3]
        elif tf in '02530':
            return self.faces[4]
        else:
            return self.faces[5]

    def is_same(self, dice):
        for i in self.faces:
            if not i in dice.faces:
                return 'No'
        top1 = self.faces[3]
        front1 = self.faces[1]
        top2 = self.faces[0]
        front2 = self.faces[3]
        top3 = self.faces[0]
        front3 = self.faces[1]
        top4 = self.faces[4]
        front4 = self.faces[5]
        top5 = self.faces[0]
        front5 = self.faces[2]
        top6 = self.faces[2]
        front6 = self.faces[1]
        if (self.find_rf(top1, front1) == dice.find_rf(top1, front1)):
            if (self.find_rf(top2, front2) == dice.find_rf(top2, front2)):
                if (self.find_rf(top3, front3) == dice.find_rf(top3, front3)):
                    if (self.find_rf(top4, front4) == dice.find_rf(top4, front4)):
                        if (self.find_rf(top5, front5) == dice.find_rf(top5, front5)):
                            if (self.find_rf(top6, front6) == dice.find_rf(top6, front6)):
                                return 'Yes'
        return 'No'

num_tuple1 = tuple(map(int, input().split()))
num_tuple2 = tuple(map(int, input().split()))

dice1 = Dice(num_tuple1)
dice2 = Dice(num_tuple2)

ans = dice1.is_same(dice2)

print(ans)