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)

import sys
class Dice:
    def __init__(self, f):
        self.f = f[:]

    def roll(self, s):
        for f in s:
            n = self.f[:]
            if f == 'E':
                t = n[0]
                n[0] = n[3]
                n[3] = n[5]
                n[5] = n[2]
                n[2] = t
            elif f == 'W':
                t = n[0]
                n[0] = n[2]
                n[2] = n[5]
                n[5] = n[3]
                n[3] = t
            elif f == 'N':
                t = n[0]
                n[0] = n[1]
                n[1] = n[5]
                n[5] = n[4]
                n[4] = t
            else:
                t = n[0]
                n[0] = n[4]
                n[4] = n[5]
                n[5] = n[1]
                n[1] = t
            self.f = n

    def to_top(self, index):
        if index == 1:
            self.roll('N')
        elif index == 2:
            self.roll('W')
        elif index == 3:
            self.roll('E')
        elif index == 4:
            self.roll('S')
        elif index == 5:
            self.roll('NN')

    def side_roll(self):
        t  = self.f[1]
        self.f[1] = self.f[2]
        self.f[2] = self.f[4]
        self.f[4] = self.f[3]
        self.f[3] = t

    def top(self):
        return self.f[0]

    def front(self):
        return self.f[1]

    def r(self):
        return self.f[2]

    def __eq__ (self, other):
        if other is None or type(self) != type(other): return False
        return self.__dict__ == other.__dict__

d1, d2 = (Dice(list(input().split())) for _ in range(2))
t2 = d1.f.index(d2.top())
d1.to_top(t2)
for _ in range(3):
    if d1 == d2:
        print('Yes')
        sys.exit(0)
    else: d1.side_roll()
print('No')