def main():

    labels1 = list(map(int, input().split(' ')))

    labels2 = list(map(int, input().split(' ')))



    dice1 = Dice(labels1)

    dice2 = Dice(labels2)



    print(('Yes' if equals(dice1, dice2) else 'No'))



def equals(d1, d2):

    for i in range(4):

        for j in range(4):

            if d1.equals(d2):

                return True

            d2.toE()

        d2.toN()



    d2.toE().toN()



    for i in range(2):

        for j in range(4):

            if d1.equals(d2):

                return True

            d2.toE()

        d2.toN().toN()



    return False



class Dice:

    def __init__(self, labels):

        self.labels = labels



        self._tb = (0, 5)

        self._fb = (1, 4)

        self._lr = (3, 2)



    def toN(self):

        tb = self._tb

        self._tb = self._fb

        self._fb = tuple(reversed(tb))



        return self



    def toS(self):

        tb = self._tb

        self._tb = tuple(reversed(self._fb))

        self._fb = tb



        return self



    def toW(self):

        tb = self._tb

        self._tb = tuple(reversed(self._lr))

        self._lr = tb



        return self



    def toE(self):

        tb = self._tb

        self._tb = self._lr

        self._lr = tuple(reversed(tb))



        return self



    def get_top(self):

        return self.labels[self._tb[0]]



    def get_bottom(self):

        return self.labels[self._tb[1]]



    def get_front(self):

        return self.labels[self._fb[0]]



    def get_back(self):

        return self.labels[self._fb[1]]



    def get_left(self):

        return self.labels[self._lr[0]]



    def get_right(self):

        return self.labels[self._lr[1]]



    top    = property(get_top)

    bottom = property(get_bottom)

    front  = property(get_front)

    back   = property(get_back)

    left   = property(get_left)

    right  = property(get_right)



    def equals(self, other):

        if not (self.top == other.top and self.bottom == other.bottom):

            return False



        if not (self.front == other.front and self.back == other.back):

            return False



        if not (self.left == other.left and self.right == other.right):

            return False



        return True



    def __str__(self):

        return str([self.top, self.front, self.right, self.left, self.back, self.bottom])



if __name__ == '__main__':

    main()
class Dice:

    def __init__(self, nums):

        self.top    = nums[0]

        self.front  = nums[1]

        self.right  = nums[2]

        self.left   = nums[3]

        self.back   = nums[4]

        self.bottom = nums[5]



    def toN(self):

        tmp = self.top

        self.top = self.front

        self.front = self.bottom

        self.bottom = self.back

        self.back = tmp



    def toS(self):

        tmp = self.top

        self.top = self.back

        self.back = self.bottom

        self.bottom = self.front

        self.front = tmp



    def toE(self):

        tmp = self.top

        self.top = self.left

        self.left = self.bottom

        self.bottom = self.right

        self.right = tmp



    def toW(self):

        tmp = self.top

        self.top = self.right

        self.right = self.bottom

        self.bottom = self.left

        self.left = tmp



    def moveTo(self, ds):

        for d in ds:

            if   d == 'N':

                self.toN()

            if d == 'S':

                self.toS()

            if d == 'E':

                self.toE()

            if d == 'W':

                self.toW()



    def getTop(self):

        return self.top



    def getBottom(self):

        return self.bottom



    def getFront(self):

        return self.front



    def getBack(self):

        return self.back



    def getLeft(self):

        return self.left



    def getRight(self):

        return self.right



    def __eq__(self, other):

        if self.top != other.top:

            return False

        if self.bottom != other.bottom:

            return False

        if self.front != other.front:

            return False

        if self.back != other.back:

            return False

        if self.left != other.left:

            return False

        if self.right != other.right:

            return False



        return True



def moveTo(dice, top, front):

    if dice.getFront() != front:

        if   dice.getTop()    == front:

            dice.moveTo("S")

        elif dice.getBottom() == front:

            dice.moveTo("N")

        elif dice.getBack()   == front:

            dice.moveTo("NN")

        elif dice.getLeft()   == front:

            dice.moveTo("ES")

        elif dice.getRight()  == front:

            dice.moveTo("WS")



    if dice.getTop() != top:

        if   dice.getBottom() == top:

            dice.moveTo("EE")

        elif dice.getLeft()   == top:

            dice.moveTo("E")

        elif dice.getRight()  == top:

            dice.moveTo("W")



    return dice



def equalDice(dice1, dice2):

    dice2 = moveTo(dice2, dice1.getTop(), dice1.getFront())

    return dice1 == dice2



def main():

    dice1 = Dice(input().split())

    dice2 = Dice(input().split())



    if equalDice(dice1, dice2):

        print("Yes")

    else:

        print("No")



if __name__ == '__main__':

    main()



def main():
    labels1 = list(map(int, input().split(" ")))
    labels2 = list(map(int, input().split(" ")))
    dice1 = Dice(labels1)
    dice2 = Dice(labels2)
    print(("Yes" if equals(dice1, dice2) else "No"))


def equals(d1, d2):
    for i in range(4):
        for j in range(4):
            if d1.equals(d2):
                return True
            d2.toE()
        d2.toN()
    d2.toE().toN()
    for i in range(2):
        for j in range(4):
            if d1.equals(d2):
                return True
            d2.toE()
        d2.toN().toN()
    return False


class Dice:
    def __init__(self, labels):
        self.labels = labels
        self._tb = (0, 5)
        self._fb = (1, 4)
        self._lr = (3, 2)

    def toN(self):
        tb = self._tb
        self._tb = self._fb
        self._fb = tuple(reversed(tb))
        return self

    def toS(self):
        tb = self._tb
        self._tb = tuple(reversed(self._fb))
        self._fb = tb
        return self

    def toW(self):
        tb = self._tb
        self._tb = tuple(reversed(self._lr))
        self._lr = tb
        return self

    def toE(self):
        tb = self._tb
        self._tb = self._lr
        self._lr = tuple(reversed(tb))
        return self

    def get_top(self):
        return self.labels[self._tb[0]]

    def get_bottom(self):
        return self.labels[self._tb[1]]

    def get_front(self):
        return self.labels[self._fb[0]]

    def get_back(self):
        return self.labels[self._fb[1]]

    def get_left(self):
        return self.labels[self._lr[0]]

    def get_right(self):
        return self.labels[self._lr[1]]

    top = property(get_top)
    bottom = property(get_bottom)
    front = property(get_front)
    back = property(get_back)
    left = property(get_left)
    right = property(get_right)

    def equals(self, other):
        if not (self.top == other.top and self.bottom == other.bottom):
            return False
        if not (self.front == other.front and self.back == other.back):
            return False
        if not (self.left == other.left and self.right == other.right):
            return False
        return True

    def __str__(self):
        return str(
            [self.top, self.front, self.right, self.left, self.back, self.bottom]
        )


if __name__ == "__main__":
    main()

class Dice:
    def __init__(self, nums):
        self.top = nums[0]
        self.front = nums[1]
        self.right = nums[2]
        self.left = nums[3]
        self.back = nums[4]
        self.bottom = nums[5]

    def toN(self):
        tmp = self.top
        self.top = self.front
        self.front = self.bottom
        self.bottom = self.back
        self.back = tmp

    def toS(self):
        tmp = self.top
        self.top = self.back
        self.back = self.bottom
        self.bottom = self.front
        self.front = tmp

    def toE(self):
        tmp = self.top
        self.top = self.left
        self.left = self.bottom
        self.bottom = self.right
        self.right = tmp

    def toW(self):
        tmp = self.top
        self.top = self.right
        self.right = self.bottom
        self.bottom = self.left
        self.left = tmp

    def moveTo(self, ds):
        for d in ds:
            if d == "N":
                self.toN()
            if d == "S":
                self.toS()
            if d == "E":
                self.toE()
            if d == "W":
                self.toW()

    def getTop(self):
        return self.top

    def getBottom(self):
        return self.bottom

    def getFront(self):
        return self.front

    def getBack(self):
        return self.back

    def getLeft(self):
        return self.left

    def getRight(self):
        return self.right

    def __eq__(self, other):
        if self.top != other.top:
            return False
        if self.bottom != other.bottom:
            return False
        if self.front != other.front:
            return False
        if self.back != other.back:
            return False
        if self.left != other.left:
            return False
        if self.right != other.right:
            return False
        return True


def moveTo(dice, top, front):
    if dice.getFront() != front:
        if dice.getTop() == front:
            dice.moveTo("S")
        elif dice.getBottom() == front:
            dice.moveTo("N")
        elif dice.getBack() == front:
            dice.moveTo("NN")
        elif dice.getLeft() == front:
            dice.moveTo("ES")
        elif dice.getRight() == front:
            dice.moveTo("WS")
    if dice.getTop() != top:
        if dice.getBottom() == top:
            dice.moveTo("EE")
        elif dice.getLeft() == top:
            dice.moveTo("E")
        elif dice.getRight() == top:
            dice.moveTo("W")
    return dice


def equalDice(dice1, dice2):
    dice2 = moveTo(dice2, dice1.getTop(), dice1.getFront())
    return dice1 == dice2


def main():
    dice1 = Dice(input().split())
    dice2 = Dice(input().split())
    if equalDice(dice1, dice2):
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()

-def main(): -    labels1 = list(map(int, input().split(" "))) -    labels2 = list(map(int, input().split(" "))) -    dice1 = Dice(labels1) -    dice2 = Dice(labels2) -    print(("Yes" if equals(dice1, dice2) else "No")) - - -def equals(d1, d2): -    for i in range(4): -        for j in range(4): -            if d1.equals(d2): -                return True -            d2.toE() -        d2.toN() -    d2.toE().toN() -    for i in range(2): -        for j in range(4): -            if d1.equals(d2): -                return True -            d2.toE() -        d2.toN().toN() -    return False - - -    def __init__(self, labels): -        self.labels = labels -        self._tb = (0, 5) -        self._fb = (1, 4) -        self._lr = (3, 2) +    def __init__(self, nums): +        self.top = nums[0] +        self.front = nums[1] +        self.right = nums[2] +        self.left = nums[3] +        self.back = nums[4] +        self.bottom = nums[5] -        tb = self._tb -        self._tb = self._fb -        self._fb = tuple(reversed(tb)) -        return self +        tmp = self.top +        self.top = self.front +        self.front = self.bottom +        self.bottom = self.back +        self.back = tmp -        tb = self._tb -        self._tb = tuple(reversed(self._fb)) -        self._fb = tb -        return self +        tmp = self.top +        self.top = self.back +        self.back = self.bottom +        self.bottom = self.front +        self.front = tmp + +    def toE(self): +        tmp = self.top +        self.top = self.left +        self.left = self.bottom +        self.bottom = self.right +        self.right = tmp -        tb = self._tb -        self._tb = tuple(reversed(self._lr)) -        self._lr = tb -        return self +        tmp = self.top +        self.top = self.right +        self.right = self.bottom +        self.bottom = self.left +        self.left = tmp -    def toE(self): -        tb = self._tb -        self._tb = self._lr -        self._lr = tuple(reversed(tb)) -        return self +    def moveTo(self, ds): +        for d in ds: +            if d == "N": +                self.toN() +            if d == "S": +                self.toS() +            if d == "E": +                self.toE() +            if d == "W": +                self.toW() -    def get_top(self): -        return self.labels[self._tb[0]] +    def getTop(self): +        return self.top -    def get_bottom(self): -        return self.labels[self._tb[1]] +    def getBottom(self): +        return self.bottom -    def get_front(self): -        return self.labels[self._fb[0]] +    def getFront(self): +        return self.front -    def get_back(self): -        return self.labels[self._fb[1]] +    def getBack(self): +        return self.back -    def get_left(self): -        return self.labels[self._lr[0]] +    def getLeft(self): +        return self.left -    def get_right(self): -        return self.labels[self._lr[1]] +    def getRight(self): +        return self.right -    top = property(get_top) -    bottom = property(get_bottom) -    front = property(get_front) -    back = property(get_back) -    left = property(get_left) -    right = property(get_right) - -    def equals(self, other): -        if not (self.top == other.top and self.bottom == other.bottom): +    def __eq__(self, other): +        if self.top != other.top: -        if not (self.front == other.front and self.back == other.back): +        if self.bottom != other.bottom: -        if not (self.left == other.left and self.right == other.right): +        if self.front != other.front: +            return False +        if self.back != other.back: +            return False +        if self.left != other.left: +            return False +        if self.right != other.right: -    def __str__(self): -        return str( -            [self.top, self.front, self.right, self.left, self.back, self.bottom] -        ) + +def moveTo(dice, top, front): +    if dice.getFront() != front: +        if dice.getTop() == front: +            dice.moveTo("S") +        elif dice.getBottom() == front: +            dice.moveTo("N") +        elif dice.getBack() == front: +            dice.moveTo("NN") +        elif dice.getLeft() == front: +            dice.moveTo("ES") +        elif dice.getRight() == front: +            dice.moveTo("WS") +    if dice.getTop() != top: +        if dice.getBottom() == top: +            dice.moveTo("EE") +        elif dice.getLeft() == top: +            dice.moveTo("E") +        elif dice.getRight() == top: +            dice.moveTo("W") +    return dice + + +def equalDice(dice1, dice2): +    dice2 = moveTo(dice2, dice1.getTop(), dice1.getFront()) +    return dice1 == dice2 + + +def main(): +    dice1 = Dice(input().split()) +    dice2 = Dice(input().split()) +    if equalDice(dice1, dice2): +        print("Yes") +    else: +        print("No")