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

n=int(eval(input()))

ans = 'No'

for i in range(n):

    d = int(eval(input()))

    for i in range(3):

        for j in range(3):

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

                a[i][j]=0



if a[0][0] == 0 and a[1][1] == 0 and a[2][2]==0:

    ans = 'Yes'

elif a[0][2] == 0 and a[1][1] == 0 and a[2][0]==0:

    ans = 'Yes'

else: 

    for l in a:

        if sum(l)==0:

            ans = 'Yes'

            break

    for l in zip(*a):

        if sum(l)==0:

            ans = 'Yes'

            break

        



print(ans)
al = []

ans = 'No'

for i in range(3):

    al.append(list(map(int, input().split())))

n = int(eval(input()))

bl = [int(eval(input())) for i in range(n)]

for i in bl:

    for a in al:

        if i in a:

            a[a.index(i)]=0           

t1 = al[0][0]+al[1][1]+al[2][2]

t2 = al[0][2]+al[1][1]+al[2][0]

if t1 ==0 or t2==0:

    ans = 'Yes'

else:

    for a in al:

        if sum(a)==0:

            ans = 'Yes'

            break

        else:

            for va in zip(*al):

                if sum(va)==0:

                    ans = 'Yes'

                    break

print(ans)





    



    





                

    

    
a = [list(map(int, input().split())) for i in range(3)]
n = int(eval(input()))
ans = "No"
for i in range(n):
    d = int(eval(input()))
    for i in range(3):
        for j in range(3):
            if d == a[i][j]:
                a[i][j] = 0
if a[0][0] == 0 and a[1][1] == 0 and a[2][2] == 0:
    ans = "Yes"
elif a[0][2] == 0 and a[1][1] == 0 and a[2][0] == 0:
    ans = "Yes"
else:
    for l in a:
        if sum(l) == 0:
            ans = "Yes"
            break
    for l in zip(*a):
        if sum(l) == 0:
            ans = "Yes"
            break
print(ans)

al = []
ans = "No"
for i in range(3):
    al.append(list(map(int, input().split())))
n = int(eval(input()))
bl = [int(eval(input())) for i in range(n)]
for i in bl:
    for a in al:
        if i in a:
            a[a.index(i)] = 0
t1 = al[0][0] + al[1][1] + al[2][2]
t2 = al[0][2] + al[1][1] + al[2][0]
if t1 == 0 or t2 == 0:
    ans = "Yes"
else:
    for a in al:
        if sum(a) == 0:
            ans = "Yes"
            break
        else:
            for va in zip(*al):
                if sum(va) == 0:
                    ans = "Yes"
                    break
print(ans)

-a = [list(map(int, input().split())) for i in range(3)] +al = [] +ans = "No" +for i in range(3): +    al.append(list(map(int, input().split()))) -ans = "No" -for i in range(n): -    d = int(eval(input())) -    for i in range(3): -        for j in range(3): -            if d == a[i][j]: -                a[i][j] = 0 -if a[0][0] == 0 and a[1][1] == 0 and a[2][2] == 0: -    ans = "Yes" -elif a[0][2] == 0 and a[1][1] == 0 and a[2][0] == 0: +bl = [int(eval(input())) for i in range(n)] +for i in bl: +    for a in al: +        if i in a: +            a[a.index(i)] = 0 +t1 = al[0][0] + al[1][1] + al[2][2] +t2 = al[0][2] + al[1][1] + al[2][0] +if t1 == 0 or t2 == 0: -    for l in a: -        if sum(l) == 0: +    for a in al: +        if sum(a) == 0: -    for l in zip(*a): -        if sum(l) == 0: -            ans = "Yes" -            break +        else: +            for va in zip(*al): +                if sum(va) == 0: +                    ans = "Yes" +                    break