import itertools





def roll(dice, commands):

    for command in commands:

        if command == 'N':

            dice[0], dice[1], dice[5], dice[4] = dice[1], dice[5], dice[4], dice[0]

        elif command == 'S':

            dice[0], dice[1], dice[5], dice[4] = dice[4], dice[0], dice[1], dice[5]

        elif command == 'W':

            dice[0], dice[3], dice[5], dice[2] = dice[2], dice[0], dice[3], dice[5]

        elif command == 'E':

            dice[0], dice[3], dice[5], dice[2] = dice[3], dice[5], dice[2], dice[0]



A = list(map(int, input().split()))

B = list(map(int, input().split()))

for i in range(4):

    for j in range(4):

        for commands in itertools.permutations('S' * i + 'W' * j):

            a = A[::]

            roll(a, commands)

            if B == a:

                print('Yes')

                exit()

print('No')
import itertools





def roll(dice, commands):

    for command in commands:

        if command == 'N':

            dice[0], dice[1], dice[5], dice[4] = dice[1], dice[5], dice[4], dice[0]

        elif command == 'W':

            dice[0], dice[3], dice[5], dice[2] = dice[2], dice[0], dice[3], dice[5]





def solve():

    A = list(map(int, input().split()))

    B = list(map(int, input().split()))

    for i in range(4):

        for j in range(4):

            for commands in itertools.permutations('N' * i + 'W' * j):

                a = A[::]

                roll(a, commands)

                if B == a:

                    return True

    return False





if __name__ == '__main__':

    print(('Yes' if solve() else 'No'))
import itertools


def roll(dice, commands):
    for command in commands:
        if command == "N":
            dice[0], dice[1], dice[5], dice[4] = dice[1], dice[5], dice[4], dice[0]
        elif command == "S":
            dice[0], dice[1], dice[5], dice[4] = dice[4], dice[0], dice[1], dice[5]
        elif command == "W":
            dice[0], dice[3], dice[5], dice[2] = dice[2], dice[0], dice[3], dice[5]
        elif command == "E":
            dice[0], dice[3], dice[5], dice[2] = dice[3], dice[5], dice[2], dice[0]


A = list(map(int, input().split()))
B = list(map(int, input().split()))
for i in range(4):
    for j in range(4):
        for commands in itertools.permutations("S" * i + "W" * j):
            a = A[::]
            roll(a, commands)
            if B == a:
                print("Yes")
                exit()
print("No")

import itertools


def roll(dice, commands):
    for command in commands:
        if command == "N":
            dice[0], dice[1], dice[5], dice[4] = dice[1], dice[5], dice[4], dice[0]
        elif command == "W":
            dice[0], dice[3], dice[5], dice[2] = dice[2], dice[0], dice[3], dice[5]


def solve():
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    for i in range(4):
        for j in range(4):
            for commands in itertools.permutations("N" * i + "W" * j):
                a = A[::]
                roll(a, commands)
                if B == a:
                    return True
    return False


if __name__ == "__main__":
    print(("Yes" if solve() else "No"))

-        elif command == "S": -            dice[0], dice[1], dice[5], dice[4] = dice[4], dice[0], dice[1], dice[5] -        elif command == "E": -            dice[0], dice[3], dice[5], dice[2] = dice[3], dice[5], dice[2], dice[0] -A = list(map(int, input().split())) -B = list(map(int, input().split())) -for i in range(4): -    for j in range(4): -        for commands in itertools.permutations("S" * i + "W" * j): -            a = A[::] -            roll(a, commands) -            if B == a: -                print("Yes") -                exit() -print("No") +def solve(): +    A = list(map(int, input().split())) +    B = list(map(int, input().split())) +    for i in range(4): +        for j in range(4): +            for commands in itertools.permutations("N" * i + "W" * j): +                a = A[::] +                roll(a, commands) +                if B == a: +                    return True +    return False + + +if __name__ == "__main__": +    print(("Yes" if solve() else "No"))