#!usr/bin/env python3



import sys





class Die:

    def __init__(self, pips):

        self.pips = pips



    def move_die(self, direction):

        if direction == 'N':

            tmp = self.pips[0]

            self.pips[0] = self.pips[1]

            self.pips[1] = self.pips[5]

            self.pips[5] = self.pips[4]

            self.pips[4] = tmp

            del tmp

        elif direction == 'S':

            tmp = self.pips[0]

            self.pips[0] = self.pips[4]

            self.pips[4] = self.pips[5]

            self.pips[5] = self.pips[1]

            self.pips[1] = tmp

            del tmp

        elif direction == 'E':

            tmp = self.pips[0]

            self.pips[0] = self.pips[3]

            self.pips[3] = self.pips[5]

            self.pips[5] = self.pips[2]

            self.pips[2] = tmp

            del tmp

        elif direction == 'W':

            tmp = self.pips[0]

            self.pips[0] = self.pips[2]

            self.pips[2] = self.pips[5]

            self.pips[5] = self.pips[3]

            self.pips[3] = tmp

            del tmp



    def spin_die_clockwise(self):

        tmp = self.pips[1]

        self.pips[1] = self.pips[2]

        self.pips[2] = self.pips[4]

        self.pips[4] = self.pips[3]

        self.pips[3] = tmp

        del tmp





def init_die():

    pips = [int(pip) for pip in sys.stdin.readline().strip('\n').split()]

    die = Die(pips)



    return die





def roll_die(die):

    directions = list(sys.stdin.readline().strip('\n'))



    for direction in directions:

        die.move_die(direction)



    return die





def question_rightside(die):

    q = int(sys.stdin.readline().strip('\n'))



    for question in range(q):

        q_pips = [int(pip) for pip in sys.stdin.readline().strip('\n').split()]



        if q_pips[0] == die.pips[1]:

            die.move_die('N')

        elif q_pips[0] == die.pips[2]:

            die.move_die('W')

        elif q_pips[0] == die.pips[3]:

            die.move_die('E')

        elif q_pips[0] == die.pips[4]:

            die.move_die('S')

        elif q_pips[0] == die.pips[5]:

            die.move_die('N')

            die.move_die('N')



        while die.pips[1] != q_pips[1]:

            die.spin_die_clockwise()



        print((die.pips[2]))





def main():

    die1 = init_die()

    die2 = init_die()



    if sorted(die1.pips) != sorted(die2.pips):

        print('No')

    else:

        for idx, pip in enumerate(die2.pips):

            for spin in range(4):

                if die1.pips == die2.pips:

                    print('Yes')

                    sys.exit(0)

                else:

                    die1.spin_die_clockwise()

            if idx in {0, 1, 2}:

                die1.move_die('N')

            if idx in {3}:

                die1.move_die('N')

                die1.move_die('E')

            if idx in {4}:

                die1.move_die('E')

                die1.move_die('E')



        print('No')





if __name__ == '__main__':

    main()
#!usr/bin/env python3



import sys





class Die:

    def __init__(self, pips):

        self.pips = pips



    def move_die(self, direction):

        if direction == 'N':

            tmp = self.pips[0]

            self.pips[0] = self.pips[1]

            self.pips[1] = self.pips[5]

            self.pips[5] = self.pips[4]

            self.pips[4] = tmp

            del tmp

        elif direction == 'S':

            tmp = self.pips[0]

            self.pips[0] = self.pips[4]

            self.pips[4] = self.pips[5]

            self.pips[5] = self.pips[1]

            self.pips[1] = tmp

            del tmp

        elif direction == 'E':

            tmp = self.pips[0]

            self.pips[0] = self.pips[3]

            self.pips[3] = self.pips[5]

            self.pips[5] = self.pips[2]

            self.pips[2] = tmp

            del tmp

        elif direction == 'W':

            tmp = self.pips[0]

            self.pips[0] = self.pips[2]

            self.pips[2] = self.pips[5]

            self.pips[5] = self.pips[3]

            self.pips[3] = tmp

            del tmp



    def spin_die_clockwise(self):

        tmp = self.pips[1]

        self.pips[1] = self.pips[2]

        self.pips[2] = self.pips[4]

        self.pips[4] = self.pips[3]

        self.pips[3] = tmp

        del tmp





def init_die():

    pips = [int(pip) for pip in sys.stdin.readline().strip('\n').split()]

    die = Die(pips)



    return die





def roll_die(die):

    directions = list(sys.stdin.readline().strip('\n'))



    for direction in directions:

        die.move_die(direction)



    return die





def question_rightside(die):

    q = int(sys.stdin.readline().strip('\n'))



    for question in range(q):

        q_pips = [int(pip) for pip in sys.stdin.readline().strip('\n').split()]



        if q_pips[0] == die.pips[1]:

            die.move_die('N')

        elif q_pips[0] == die.pips[2]:

            die.move_die('W')

        elif q_pips[0] == die.pips[3]:

            die.move_die('E')

        elif q_pips[0] == die.pips[4]:

            die.move_die('S')

        elif q_pips[0] == die.pips[5]:

            die.move_die('N')

            die.move_die('N')



        while die.pips[1] != q_pips[1]:

            die.spin_die_clockwise()



        print((die.pips[2]))





def are_identical(die1, die2):

    if sorted(die1.pips) != sorted(die2.pips):

        return 'No'

    else:

        for idx, pip in enumerate(die2.pips):

            for spin in range(4):

                if die1.pips == die2.pips:

                    return 'Yes'

                else:

                    die1.spin_die_clockwise()

            if idx in {0, 1, 2}:

                die1.move_die('N')

            if idx in {3}:

                die1.move_die('N')

                die1.move_die('E')

            if idx in {4}:

                die1.move_die('E')

                die1.move_die('E')



        return 'No'





def main():

    die1 = init_die()

    die2 = init_die()

    print((are_identical(die1, die2)))





if __name__ == '__main__':

    main()
#!usr/bin/env python3
import sys


class Die:
    def __init__(self, pips):
        self.pips = pips

    def move_die(self, direction):
        if direction == "N":
            tmp = self.pips[0]
            self.pips[0] = self.pips[1]
            self.pips[1] = self.pips[5]
            self.pips[5] = self.pips[4]
            self.pips[4] = tmp
            del tmp
        elif direction == "S":
            tmp = self.pips[0]
            self.pips[0] = self.pips[4]
            self.pips[4] = self.pips[5]
            self.pips[5] = self.pips[1]
            self.pips[1] = tmp
            del tmp
        elif direction == "E":
            tmp = self.pips[0]
            self.pips[0] = self.pips[3]
            self.pips[3] = self.pips[5]
            self.pips[5] = self.pips[2]
            self.pips[2] = tmp
            del tmp
        elif direction == "W":
            tmp = self.pips[0]
            self.pips[0] = self.pips[2]
            self.pips[2] = self.pips[5]
            self.pips[5] = self.pips[3]
            self.pips[3] = tmp
            del tmp

    def spin_die_clockwise(self):
        tmp = self.pips[1]
        self.pips[1] = self.pips[2]
        self.pips[2] = self.pips[4]
        self.pips[4] = self.pips[3]
        self.pips[3] = tmp
        del tmp


def init_die():
    pips = [int(pip) for pip in sys.stdin.readline().strip("\n").split()]
    die = Die(pips)
    return die


def roll_die(die):
    directions = list(sys.stdin.readline().strip("\n"))
    for direction in directions:
        die.move_die(direction)
    return die


def question_rightside(die):
    q = int(sys.stdin.readline().strip("\n"))
    for question in range(q):
        q_pips = [int(pip) for pip in sys.stdin.readline().strip("\n").split()]
        if q_pips[0] == die.pips[1]:
            die.move_die("N")
        elif q_pips[0] == die.pips[2]:
            die.move_die("W")
        elif q_pips[0] == die.pips[3]:
            die.move_die("E")
        elif q_pips[0] == die.pips[4]:
            die.move_die("S")
        elif q_pips[0] == die.pips[5]:
            die.move_die("N")
            die.move_die("N")
        while die.pips[1] != q_pips[1]:
            die.spin_die_clockwise()
        print((die.pips[2]))


def main():
    die1 = init_die()
    die2 = init_die()
    if sorted(die1.pips) != sorted(die2.pips):
        print("No")
    else:
        for idx, pip in enumerate(die2.pips):
            for spin in range(4):
                if die1.pips == die2.pips:
                    print("Yes")
                    sys.exit(0)
                else:
                    die1.spin_die_clockwise()
            if idx in {0, 1, 2}:
                die1.move_die("N")
            if idx in {3}:
                die1.move_die("N")
                die1.move_die("E")
            if idx in {4}:
                die1.move_die("E")
                die1.move_die("E")
        print("No")


if __name__ == "__main__":
    main()

#!usr/bin/env python3
import sys


class Die:
    def __init__(self, pips):
        self.pips = pips

    def move_die(self, direction):
        if direction == "N":
            tmp = self.pips[0]
            self.pips[0] = self.pips[1]
            self.pips[1] = self.pips[5]
            self.pips[5] = self.pips[4]
            self.pips[4] = tmp
            del tmp
        elif direction == "S":
            tmp = self.pips[0]
            self.pips[0] = self.pips[4]
            self.pips[4] = self.pips[5]
            self.pips[5] = self.pips[1]
            self.pips[1] = tmp
            del tmp
        elif direction == "E":
            tmp = self.pips[0]
            self.pips[0] = self.pips[3]
            self.pips[3] = self.pips[5]
            self.pips[5] = self.pips[2]
            self.pips[2] = tmp
            del tmp
        elif direction == "W":
            tmp = self.pips[0]
            self.pips[0] = self.pips[2]
            self.pips[2] = self.pips[5]
            self.pips[5] = self.pips[3]
            self.pips[3] = tmp
            del tmp

    def spin_die_clockwise(self):
        tmp = self.pips[1]
        self.pips[1] = self.pips[2]
        self.pips[2] = self.pips[4]
        self.pips[4] = self.pips[3]
        self.pips[3] = tmp
        del tmp


def init_die():
    pips = [int(pip) for pip in sys.stdin.readline().strip("\n").split()]
    die = Die(pips)
    return die


def roll_die(die):
    directions = list(sys.stdin.readline().strip("\n"))
    for direction in directions:
        die.move_die(direction)
    return die


def question_rightside(die):
    q = int(sys.stdin.readline().strip("\n"))
    for question in range(q):
        q_pips = [int(pip) for pip in sys.stdin.readline().strip("\n").split()]
        if q_pips[0] == die.pips[1]:
            die.move_die("N")
        elif q_pips[0] == die.pips[2]:
            die.move_die("W")
        elif q_pips[0] == die.pips[3]:
            die.move_die("E")
        elif q_pips[0] == die.pips[4]:
            die.move_die("S")
        elif q_pips[0] == die.pips[5]:
            die.move_die("N")
            die.move_die("N")
        while die.pips[1] != q_pips[1]:
            die.spin_die_clockwise()
        print((die.pips[2]))


def are_identical(die1, die2):
    if sorted(die1.pips) != sorted(die2.pips):
        return "No"
    else:
        for idx, pip in enumerate(die2.pips):
            for spin in range(4):
                if die1.pips == die2.pips:
                    return "Yes"
                else:
                    die1.spin_die_clockwise()
            if idx in {0, 1, 2}:
                die1.move_die("N")
            if idx in {3}:
                die1.move_die("N")
                die1.move_die("E")
            if idx in {4}:
                die1.move_die("E")
                die1.move_die("E")
        return "No"


def main():
    die1 = init_die()
    die2 = init_die()
    print((are_identical(die1, die2)))


if __name__ == "__main__":
    main()

-def main(): -    die1 = init_die() -    die2 = init_die() +def are_identical(die1, die2): -        print("No") +        return "No" -                    print("Yes") -                    sys.exit(0) +                    return "Yes" -        print("No") +        return "No" + + +def main(): +    die1 = init_die() +    die2 = init_die() +    print((are_identical(die1, die2)))