class Dice:

    def __init__(self):

        self.faces=[]



    def rotate(self, direction):

        tmp = self.faces.copy()



        if direction =="N":

            self.faces[5-1] = tmp[1-1]

            self.faces[1-1] = tmp[2-1]

            self.faces[2-1] = tmp[6-1]

            self.faces[6-1] = tmp[5-1]

        if direction =="S":

            self.faces[5-1] = tmp[6-1]

            self.faces[1-1] = tmp[5-1]

            self.faces[2-1] = tmp[1-1]

            self.faces[6-1] = tmp[2-1]

        if direction =="W":

            self.faces[4-1] = tmp[1-1]

            self.faces[1-1] = tmp[3-1]

            self.faces[3-1] = tmp[6-1]

            self.faces[6-1] = tmp[4-1]

        if direction =="E":

            self.faces[3-1] = tmp[1-1]

            self.faces[1-1] = tmp[4-1]

            self.faces[4-1] = tmp[6-1]

            self.faces[6-1] = tmp[3-1]

        return 0



    def spin(self):

        self.faces[4-1], self.faces[2-1],self.faces[5-1],self.faces[3-1] =\

        self.faces[2-1], self.faces[3-1],self.faces[4-1],self.faces[5-1]



        return 0



d1 = Dice()

d2 = Dice()

d1.faces=[int(x) for x in input().split(" ")]

d2.faces=[int(x) for x in input().split(" ")]

up,front = d1.faces[0], d1.faces[1]



res = "No"

#set up side

for _ in range(3):

    for _ in range(4):

        for ___ in range(4):

            #print("d1: {}".format(d1.faces))

            #print("d2: {}".format(d2.faces))

            if d1.faces == d2.faces:

                res = "Yes"

                break

            d2.spin()

        d2.rotate("W")

    d2.rotate("N")



print(res)

def roll(l, command):

    '''

    return rolled list



    l : string list

    command: string

    '''

    res = []

    i = -1

    if command =='N':

        res = [l[i+2], l[i+6], l[i+3], l[i+4], l[i+1], l[i+5]]

    if command =='S':

        res = [l[i+5], l[i+1], l[i+3], l[i+4], l[i+6], l[i+2]]

    if command =='E':

        res = [l[i+4], l[i+2], l[i+1], l[i+6], l[i+5], l[i+3]]

    if command =='W':

        res = [l[i+3], l[i+2], l[i+6], l[i+1], l[i+5], l[i+4]]



    return res



def spin(l):

    '''

    return right sppined list



    l : string list

    '''



    i = -1

    res = [l[i+1], l[i+3], l[i+5], l[i+2], l[i+4], l[i+6]]



    return res

def has_same_faces(a, b):

    '''

    check if all elements of a are equel to those of b.

    a : string list

    b : string list

    '''

    return set(a) == set(b)



def is_identical_lists(a, b):

    for x, y in zip(a, b):

        if x != y:

            return False



    return True



def check_two_dice(a, b):

    if not has_same_faces(a, b):

        return False

    

    orig_a = a[:]



    #roll and spin to check

    for i in range(6):

        if 1 <= i <= 3:

            a = roll(a, "N")

        elif i == 4:

            pass

            a = orig_a[:]

            a = roll(a, "W")

        elif i == 5:

            a = orig_a[:]

            a = roll(a, "E")



        # spin 4 times

        for _ in range(4): #spin 3 times

            a = spin(a)

            if is_identical_lists(a, b):

                return True

        

    return False





if __name__ == "__main__":

    a_list = input().split()

    b_list = input().split()

    res = check_two_dice(a_list, b_list)  

    print("Yes") if res else print("No")









class Dice:
    def __init__(self):
        self.faces = []

    def rotate(self, direction):
        tmp = self.faces.copy()
        if direction == "N":
            self.faces[5 - 1] = tmp[1 - 1]
            self.faces[1 - 1] = tmp[2 - 1]
            self.faces[2 - 1] = tmp[6 - 1]
            self.faces[6 - 1] = tmp[5 - 1]
        if direction == "S":
            self.faces[5 - 1] = tmp[6 - 1]
            self.faces[1 - 1] = tmp[5 - 1]
            self.faces[2 - 1] = tmp[1 - 1]
            self.faces[6 - 1] = tmp[2 - 1]
        if direction == "W":
            self.faces[4 - 1] = tmp[1 - 1]
            self.faces[1 - 1] = tmp[3 - 1]
            self.faces[3 - 1] = tmp[6 - 1]
            self.faces[6 - 1] = tmp[4 - 1]
        if direction == "E":
            self.faces[3 - 1] = tmp[1 - 1]
            self.faces[1 - 1] = tmp[4 - 1]
            self.faces[4 - 1] = tmp[6 - 1]
            self.faces[6 - 1] = tmp[3 - 1]
        return 0

    def spin(self):
        self.faces[4 - 1], self.faces[2 - 1], self.faces[5 - 1], self.faces[3 - 1] = (
            self.faces[2 - 1],
            self.faces[3 - 1],
            self.faces[4 - 1],
            self.faces[5 - 1],
        )
        return 0


d1 = Dice()
d2 = Dice()
d1.faces = [int(x) for x in input().split(" ")]
d2.faces = [int(x) for x in input().split(" ")]
up, front = d1.faces[0], d1.faces[1]
res = "No"
# set up side
for _ in range(3):
    for _ in range(4):
        for ___ in range(4):
            # print("d1: {}".format(d1.faces))
            # print("d2: {}".format(d2.faces))
            if d1.faces == d2.faces:
                res = "Yes"
                break
            d2.spin()
        d2.rotate("W")
    d2.rotate("N")
print(res)

def roll(l, command):
    """
    return rolled list
    l : string list
    command: string
    """
    res = []
    i = -1
    if command == "N":
        res = [l[i + 2], l[i + 6], l[i + 3], l[i + 4], l[i + 1], l[i + 5]]
    if command == "S":
        res = [l[i + 5], l[i + 1], l[i + 3], l[i + 4], l[i + 6], l[i + 2]]
    if command == "E":
        res = [l[i + 4], l[i + 2], l[i + 1], l[i + 6], l[i + 5], l[i + 3]]
    if command == "W":
        res = [l[i + 3], l[i + 2], l[i + 6], l[i + 1], l[i + 5], l[i + 4]]
    return res


def spin(l):
    """
    return right sppined list
    l : string list
    """
    i = -1
    res = [l[i + 1], l[i + 3], l[i + 5], l[i + 2], l[i + 4], l[i + 6]]
    return res


def has_same_faces(a, b):
    """
    check if all elements of a are equel to those of b.
    a : string list
    b : string list
    """
    return set(a) == set(b)


def is_identical_lists(a, b):
    for x, y in zip(a, b):
        if x != y:
            return False
    return True


def check_two_dice(a, b):
    if not has_same_faces(a, b):
        return False
    orig_a = a[:]
    # roll and spin to check
    for i in range(6):
        if 1 <= i <= 3:
            a = roll(a, "N")
        elif i == 4:
            pass
            a = orig_a[:]
            a = roll(a, "W")
        elif i == 5:
            a = orig_a[:]
            a = roll(a, "E")
        # spin 4 times
        for _ in range(4):  # spin 3 times
            a = spin(a)
            if is_identical_lists(a, b):
                return True
    return False


if __name__ == "__main__":
    a_list = input().split()
    b_list = input().split()
    res = check_two_dice(a_list, b_list)
    print("Yes") if res else print("No")

-class Dice: -    def __init__(self): -        self.faces = [] - -    def rotate(self, direction): -        tmp = self.faces.copy() -        if direction == "N": -            self.faces[5 - 1] = tmp[1 - 1] -            self.faces[1 - 1] = tmp[2 - 1] -            self.faces[2 - 1] = tmp[6 - 1] -            self.faces[6 - 1] = tmp[5 - 1] -        if direction == "S": -            self.faces[5 - 1] = tmp[6 - 1] -            self.faces[1 - 1] = tmp[5 - 1] -            self.faces[2 - 1] = tmp[1 - 1] -            self.faces[6 - 1] = tmp[2 - 1] -        if direction == "W": -            self.faces[4 - 1] = tmp[1 - 1] -            self.faces[1 - 1] = tmp[3 - 1] -            self.faces[3 - 1] = tmp[6 - 1] -            self.faces[6 - 1] = tmp[4 - 1] -        if direction == "E": -            self.faces[3 - 1] = tmp[1 - 1] -            self.faces[1 - 1] = tmp[4 - 1] -            self.faces[4 - 1] = tmp[6 - 1] -            self.faces[6 - 1] = tmp[3 - 1] -        return 0 - -    def spin(self): -        self.faces[4 - 1], self.faces[2 - 1], self.faces[5 - 1], self.faces[3 - 1] = ( -            self.faces[2 - 1], -            self.faces[3 - 1], -            self.faces[4 - 1], -            self.faces[5 - 1], -        ) -        return 0 +def roll(l, command): +    """ +    return rolled list +    l : string list +    command: string +    """ +    res = [] +    i = -1 +    if command == "N": +        res = [l[i + 2], l[i + 6], l[i + 3], l[i + 4], l[i + 1], l[i + 5]] +    if command == "S": +        res = [l[i + 5], l[i + 1], l[i + 3], l[i + 4], l[i + 6], l[i + 2]] +    if command == "E": +        res = [l[i + 4], l[i + 2], l[i + 1], l[i + 6], l[i + 5], l[i + 3]] +    if command == "W": +        res = [l[i + 3], l[i + 2], l[i + 6], l[i + 1], l[i + 5], l[i + 4]] +    return res -d1 = Dice() -d2 = Dice() -d1.faces = [int(x) for x in input().split(" ")] -d2.faces = [int(x) for x in input().split(" ")] -up, front = d1.faces[0], d1.faces[1] -res = "No" -# set up side -for _ in range(3): -    for _ in range(4): -        for ___ in range(4): -            # print("d1: {}".format(d1.faces)) -            # print("d2: {}".format(d2.faces)) -            if d1.faces == d2.faces: -                res = "Yes" -                break -            d2.spin() -        d2.rotate("W") -    d2.rotate("N") -print(res) +def spin(l): +    """ +    return right sppined list +    l : string list +    """ +    i = -1 +    res = [l[i + 1], l[i + 3], l[i + 5], l[i + 2], l[i + 4], l[i + 6]] +    return res + + +def has_same_faces(a, b): +    """ +    check if all elements of a are equel to those of b. +    a : string list +    b : string list +    """ +    return set(a) == set(b) + + +def is_identical_lists(a, b): +    for x, y in zip(a, b): +        if x != y: +            return False +    return True + + +def check_two_dice(a, b): +    if not has_same_faces(a, b): +        return False +    orig_a = a[:] +    # roll and spin to check +    for i in range(6): +        if 1 <= i <= 3: +            a = roll(a, "N") +        elif i == 4: +            pass +            a = orig_a[:] +            a = roll(a, "W") +        elif i == 5: +            a = orig_a[:] +            a = roll(a, "E") +        # spin 4 times +        for _ in range(4):  # spin 3 times +            a = spin(a) +            if is_identical_lists(a, b): +                return True +    return False + + +if __name__ == "__main__": +    a_list = input().split() +    b_list = input().split() +    res = check_two_dice(a_list, b_list) +    print("Yes") if res else print("No")