### BUGGY CODE ###

n1 = [int(i) for i in input().split()]
n2 = [int(i) for i in input().split()]


class Dice(object):
    def __init__(self,num):
        self.n = num[4]
        self.e = num[2]
        self.w = num[3]
        self.s = num[1]
        self.center = num[0]
        self.back = num[5]

    def number(self):
        number = [self.center, self.s, self.e, self.w, self.n, self.back]
        return number

    def move(self,str):
        if str == 'N':
            x = self.n
            self.n = self.center
            self.center = self.s
            self.s = self.back
            self.back = x
            return self.center
        elif str == 'S':
            x = self.s
            self.s = self.center
            self.center = self.n
            self.n = self.back
            self.back = x
            return self.center
        elif str== 'E':
            x = self.e
            self.e = self.center
            self.center = self.w
            self.w = self.back
            self.back = x
            return self.center
        elif str == 'W':
            x = self.w
            self.w = self.center
            self.center = self.e
            self.e = self.back
            self.back = x
            return self.center

dice1 = Dice(n1)
dice2 = Dice(n2)
bool1 = False
bool2 = False
status = dice1.center

while True:
    if dice1.number == dice2.number:
        bool1 = True
        break
    dice1.move('N')
    if status == dice1.center:
        for j in range(4):
            if dice1.number == dice2.number:
                bool1 = True
                break
            dice1.move('E')



dice1 = Dice(n1)
dice2 = Dice(n2)
status = dice1.center

while True:
    if dice1.number == dice2.number:
        bool2 = True
        break
    dice1.move('E')
    if status == dice1.center:
        while True:
            if dice1.number == dice2.number:
                bool2 = True
                break
            dice1.move('N')


print('Yes') if bool1 == True or bool2 == True else print('No')

### FIXED CODE ###

n1 = [int(i) for i in input().split()]
n2 = [int(i) for i in input().split()]


class Dice(object):
    def __init__(self,num):
        self.n = num[4]
        self.e = num[2]
        self.w = num[3]
        self.s = num[1]
        self.center = num[0]
        self.back = num[5]

    def number(self):
        number = [self.center, self.s, self.e, self.w, self.n, self.back]
        return number

    def move(self,str):
        if str == 'N':
            x = self.n
            self.n = self.center
            self.center = self.s
            self.s = self.back
            self.back = x
            return self.center
        elif str == 'S':
            x = self.s
            self.s = self.center
            self.center = self.n
            self.n = self.back
            self.back = x
            return self.center
        elif str== 'E':
            x = self.e
            self.e = self.center
            self.center = self.w
            self.w = self.back
            self.back = x
            return self.center
        elif str == 'W':
            x = self.w
            self.w = self.center
            self.center = self.e
            self.e = self.back
            self.back = x
            return self.center

dice1 = Dice(n1)
dice2 = Dice(n2)
bool = False
status = dice1.center


for i in range(4):
    for j in range(4):
        for k in range(4):
            # print(dice1.number(), dice2.number())
            if dice1.number() == dice2.number():
                bool = True
            else:
                dice1.move('N')
                dice1.move('E')
                dice1.move('S')
        dice1.move('E')
    dice1.move('N')




print('Yes') if bool == True else print('No')