al = [input().split() for _ in range(3)]

n = int(eval(input()))

for _ in range(n):

    b = eval(input())

    for i in range(3):

        for j in range(3):

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

                al[i][j] = "0"



if al[0][0]=="0" and al[0][1]=="0" and al[0][2]=="0":

    print("Yes")

elif al[1][0]=="0" and al[1][1]=="0" and al[1][2]=="0":

    print("Yes")

elif al[2][0]=="0" and al[2][1]=="0" and al[2][2]=="0":

    print("Yes")

elif al[0][0]=="0" and al[1][0]=="0" and al[2][0]=="0":

    print("Yes")

elif al[0][1]=="0" and al[1][1]=="0" and al[2][1]=="0":

    print("Yes")

elif al[0][2]=="0" and al[1][2]=="0" and al[2][2]=="0":

    print("Yes")

elif al[0][0]=="0" and al[1][1]=="0" and al[2][2]=="0":

    print("Yes")

elif al[0][2]=="0" and al[1][1]=="0" and al[2][0]=="0":

    print("Yes")

else:

    print("No")
al = [list(map(int, input().split())) for _ in range(3)]

n = int(eval(input()))



for _ in range(n):

    x = int(eval(input()))

    for i in range(3):

        for j in range(3):

            if al[i][j]==x:

                al[i][j] = -1



for i in range(3):

    if -3==sum(al[i]):

        print("Yes")

        exit()



    if -3==sum([al[j][i] for j in range(3)]):

        print("Yes")

        exit()



if al[0][0]+al[1][1]+al[2][2]==-3:

    print("Yes")

    exit()

if al[0][2]+al[1][1]+al[2][0]==-3:

    print("Yes")

    exit()



print("No")

al = [input().split() for _ in range(3)]
n = int(eval(input()))
for _ in range(n):
    b = eval(input())
    for i in range(3):
        for j in range(3):
            if al[i][j] == b:
                al[i][j] = "0"
if al[0][0] == "0" and al[0][1] == "0" and al[0][2] == "0":
    print("Yes")
elif al[1][0] == "0" and al[1][1] == "0" and al[1][2] == "0":
    print("Yes")
elif al[2][0] == "0" and al[2][1] == "0" and al[2][2] == "0":
    print("Yes")
elif al[0][0] == "0" and al[1][0] == "0" and al[2][0] == "0":
    print("Yes")
elif al[0][1] == "0" and al[1][1] == "0" and al[2][1] == "0":
    print("Yes")
elif al[0][2] == "0" and al[1][2] == "0" and al[2][2] == "0":
    print("Yes")
elif al[0][0] == "0" and al[1][1] == "0" and al[2][2] == "0":
    print("Yes")
elif al[0][2] == "0" and al[1][1] == "0" and al[2][0] == "0":
    print("Yes")
else:
    print("No")

al = [list(map(int, input().split())) for _ in range(3)]
n = int(eval(input()))
for _ in range(n):
    x = int(eval(input()))
    for i in range(3):
        for j in range(3):
            if al[i][j] == x:
                al[i][j] = -1
for i in range(3):
    if -3 == sum(al[i]):
        print("Yes")
        exit()
    if -3 == sum([al[j][i] for j in range(3)]):
        print("Yes")
        exit()
if al[0][0] + al[1][1] + al[2][2] == -3:
    print("Yes")
    exit()
if al[0][2] + al[1][1] + al[2][0] == -3:
    print("Yes")
    exit()
print("No")

-al = [input().split() for _ in range(3)] +al = [list(map(int, input().split())) for _ in range(3)] -    b = eval(input()) +    x = int(eval(input())) -            if al[i][j] == b: -                al[i][j] = "0" -if al[0][0] == "0" and al[0][1] == "0" and al[0][2] == "0": +            if al[i][j] == x: +                al[i][j] = -1 +for i in range(3): +    if -3 == sum(al[i]): +        print("Yes") +        exit() +    if -3 == sum([al[j][i] for j in range(3)]): +        print("Yes") +        exit() +if al[0][0] + al[1][1] + al[2][2] == -3: -elif al[1][0] == "0" and al[1][1] == "0" and al[1][2] == "0": +    exit() +if al[0][2] + al[1][1] + al[2][0] == -3: -elif al[2][0] == "0" and al[2][1] == "0" and al[2][2] == "0": -    print("Yes") -elif al[0][0] == "0" and al[1][0] == "0" and al[2][0] == "0": -    print("Yes") -elif al[0][1] == "0" and al[1][1] == "0" and al[2][1] == "0": -    print("Yes") -elif al[0][2] == "0" and al[1][2] == "0" and al[2][2] == "0": -    print("Yes") -elif al[0][0] == "0" and al[1][1] == "0" and al[2][2] == "0": -    print("Yes") -elif al[0][2] == "0" and al[1][1] == "0" and al[2][0] == "0": -    print("Yes") -else: -    print("No") +    exit() +print("No")