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

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

z = [0, 1, 2]

for i in range(6):

    order = [0, 0, 0]

    for j in range(3):

        if {x[j], x[-j-1]} != {y[z[j]], y[-z[j]-1]}:

            break

        if x[j] == y[z[j]]:

            order[j] = 1 

            if x[j] == x[-j-1]:

                order[j] = 2 

    else:

        if 2 in order or (i < 3) == sum(order) % 2:

            print('Yes')

            break

    z = z[-1:] + z[:-1]

    if i == 2:

        z = [z[0], z[2], z[1]]

else:

    print('No')
x = list(map(int, input().split()))

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

z = [0, 1, 2]

for i in range(6):

    order = [0, 0, 0]

    for j in range(3):

        if {x[j], x[-j-1]} != {y[z[j]], y[-z[j]-1]}:

            break

        if x[j] == y[z[j]]:

            order[j] = 1 

            if x[j] == x[-j-1]:

                order[j] = 2 

    else:

        if 2 in order or (i < 3) == sum(order) % 2:

            print('Yes')

            break

    z = [z[2], z[0], z[1]]

    if i == 2:

        z = [z[0], z[2], z[1]]

else:

    print('No')
x = list(map(int, input().split()))
y = list(map(int, input().split()))
z = [0, 1, 2]
for i in range(6):
    order = [0, 0, 0]
    for j in range(3):
        if {x[j], x[-j - 1]} != {y[z[j]], y[-z[j] - 1]}:
            break
        if x[j] == y[z[j]]:
            order[j] = 1
            if x[j] == x[-j - 1]:
                order[j] = 2
    else:
        if 2 in order or (i < 3) == sum(order) % 2:
            print("Yes")
            break
    z = z[-1:] + z[:-1]
    if i == 2:
        z = [z[0], z[2], z[1]]
else:
    print("No")

x = list(map(int, input().split()))
y = list(map(int, input().split()))
z = [0, 1, 2]
for i in range(6):
    order = [0, 0, 0]
    for j in range(3):
        if {x[j], x[-j - 1]} != {y[z[j]], y[-z[j] - 1]}:
            break
        if x[j] == y[z[j]]:
            order[j] = 1
            if x[j] == x[-j - 1]:
                order[j] = 2
    else:
        if 2 in order or (i < 3) == sum(order) % 2:
            print("Yes")
            break
    z = [z[2], z[0], z[1]]
    if i == 2:
        z = [z[0], z[2], z[1]]
else:
    print("No")

-    z = z[-1:] + z[:-1] +    z = [z[2], z[0], z[1]]