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)

def roll(die, d):
    if d == "E":
        return [die[3], die[1], die[0], die[5], die[4], die[2]]
    if d == "N":
        return [die[1], die[5], die[2], die[3], die[0], die[4]]
    if d == "S":
        return [die[4], die[0], die[2], die[3], die[5], die[1]]
    if d == "W":
        return [die[2], die[1], die[5], die[0], die[4], die[3]]
    if d == "L":
        return [die[0], die[3], die[1], die[4], die[2], die[5]]
    if d == "R":
        return [die[0], die[2], die[4], die[1], die[3], die[5]]

def checkdice(die1, die2):
    a, b = die1[:2]
    ans = True
    if die2[0] == a:
        pass
    elif die2[1] == a:
        die2 = roll(die2, "N")
    elif die2[2] == a:
        die2 = roll(die2, "W")
    elif die2[3] == a:
        die2 = roll(die2, "E")
    elif die2[4] == a:
        die2 = roll(die2, "S")
    elif die2[5] == a:
        die2 = roll(roll(die2, "E"), "E")
    else:
        ans = False
    for i in range(4):
        if die2[1] == b:
            break
        die2 = roll(die2, "R")
    for i in range(6):
        if die1[i] != die2[i]:
            ans = False
    return ans

die1 = list(map(int, input().split()))
die2 = list(map(int, input().split()))
if checkdice(die1, die2) is True:
    print("Yes")
else:
    print("No")