import numpy as np



a = [list(map(int, input().split())) for _ in range(3)]

a = np.array(a)

n = int(eval(input()))



for _ in range(n):

    b = int(eval(input()))

    

    for j in range(3):

        for i in range(3):

            if a[j][i] == b:

                a[j][i] = 0



at = a.transpose()

flag = False

for i in range(3):

    if sum(a[:][i]) == 0 or sum(at[:][i]) == 0:

        flag = True

        break

diag = a[0][0] + a[1][1] + a[2][2]

diag2 = a[2][0] + a[1][1] + a[0][2]

if diag == 0 or diag2 == 0:

    flag = True



print(("Yes" if flag else "No"))
a = [list(map(int, input().split())) for _ in range(3)]

n = int(eval(input()))

b = [int(eval(input())) for _ in range(n)]



flag = False

for i in range(3):

    if a[i][0] in b and a[i][1] in b and a[i][2] in b:

        flag = True

        break

    if a[0][i] in b and a[1][i] in b and a[2][i] in b:

        flag = True

        break

if a[0][0] in b and a[1][1] in b and a[2][2] in b:

    flag = True

if a[2][0] in b and a[1][1] in b and a[0][2] in b:

    flag = True

    

print(("Yes" if flag else "No"))
import numpy as np

a = [list(map(int, input().split())) for _ in range(3)]
a = np.array(a)
n = int(eval(input()))
for _ in range(n):
    b = int(eval(input()))
    for j in range(3):
        for i in range(3):
            if a[j][i] == b:
                a[j][i] = 0
at = a.transpose()
flag = False
for i in range(3):
    if sum(a[:][i]) == 0 or sum(at[:][i]) == 0:
        flag = True
        break
diag = a[0][0] + a[1][1] + a[2][2]
diag2 = a[2][0] + a[1][1] + a[0][2]
if diag == 0 or diag2 == 0:
    flag = True
print(("Yes" if flag else "No"))

a = [list(map(int, input().split())) for _ in range(3)]
n = int(eval(input()))
b = [int(eval(input())) for _ in range(n)]
flag = False
for i in range(3):
    if a[i][0] in b and a[i][1] in b and a[i][2] in b:
        flag = True
        break
    if a[0][i] in b and a[1][i] in b and a[2][i] in b:
        flag = True
        break
if a[0][0] in b and a[1][1] in b and a[2][2] in b:
    flag = True
if a[2][0] in b and a[1][1] in b and a[0][2] in b:
    flag = True
print(("Yes" if flag else "No"))

-import numpy as np - -a = np.array(a) -for _ in range(n): -    b = int(eval(input())) -    for j in range(3): -        for i in range(3): -            if a[j][i] == b: -                a[j][i] = 0 -at = a.transpose() +b = [int(eval(input())) for _ in range(n)] -    if sum(a[:][i]) == 0 or sum(at[:][i]) == 0: +    if a[i][0] in b and a[i][1] in b and a[i][2] in b: -diag = a[0][0] + a[1][1] + a[2][2] -diag2 = a[2][0] + a[1][1] + a[0][2] -if diag == 0 or diag2 == 0: +    if a[0][i] in b and a[1][i] in b and a[2][i] in b: +        flag = True +        break +if a[0][0] in b and a[1][1] in b and a[2][2] in b: +    flag = True +if a[2][0] in b and a[1][1] in b and a[0][2] in b: