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

N = int(eval(input()))

B = [int(eval(input())) for _ in range(N)]

for i in range(3):

    bng = 1

    for j in range(3):

        if A[i][j] in B:

            continue

        else:

            bng = 0

            break

    if bng ==1:break

if bng==1:

    print("Yes")

else:

    for j in range(3):

        bng = 1

        for i in range(3):

            if A[i][j] in B:

                continue

            else:

                bng = 0

                break

        if bng==1:break

    if bng==1:

        print("Yes")

    else:

        if A[0][0] in B and A[1][1] in B and A[2][2] in B:

            print("Yes")

        elif A[0][2] in B and A[1][1] in B and A[2][0] in B:

            print("Yes")

        else:

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

N = int(eval(input()))

B = [[0 for _ in range(3)] for _ in range(3)]

for _ in range(N):

    b = int(eval(input()))

    for i in range(3):

        for j in range(3):

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

                B[i][j] = 1

flag = 0

for i in range(3):

    if sum(B[i])==3:

        flag = 1

        break

for j in range(3):

    cnt = 0

    for i in range(3):

        cnt += B[i][j]

    if cnt==3:

        flag = 1

        break

if B[0][0]+B[1][1]+B[2][2]==3:

    flag = 1

if B[2][0]+B[1][1]+B[0][2]==3:

    flag = 1

if flag==1:

    print("Yes")

else:

    print("No")
A = [list(map(int, input().split())) for _ in range(3)]
N = int(eval(input()))
B = [int(eval(input())) for _ in range(N)]
for i in range(3):
    bng = 1
    for j in range(3):
        if A[i][j] in B:
            continue
        else:
            bng = 0
            break
    if bng == 1:
        break
if bng == 1:
    print("Yes")
else:
    for j in range(3):
        bng = 1
        for i in range(3):
            if A[i][j] in B:
                continue
            else:
                bng = 0
                break
        if bng == 1:
            break
    if bng == 1:
        print("Yes")
    else:
        if A[0][0] in B and A[1][1] in B and A[2][2] in B:
            print("Yes")
        elif A[0][2] in B and A[1][1] in B and A[2][0] in B:
            print("Yes")
        else:
            print("No")

A = [list(map(int, input().split())) for _ in range(3)]
N = int(eval(input()))
B = [[0 for _ in range(3)] for _ in range(3)]
for _ in range(N):
    b = int(eval(input()))
    for i in range(3):
        for j in range(3):
            if A[i][j] == b:
                B[i][j] = 1
flag = 0
for i in range(3):
    if sum(B[i]) == 3:
        flag = 1
        break
for j in range(3):
    cnt = 0
    for i in range(3):
        cnt += B[i][j]
    if cnt == 3:
        flag = 1
        break
if B[0][0] + B[1][1] + B[2][2] == 3:
    flag = 1
if B[2][0] + B[1][1] + B[0][2] == 3:
    flag = 1
if flag == 1:
    print("Yes")
else:
    print("No")

-B = [int(eval(input())) for _ in range(N)] +B = [[0 for _ in range(3)] for _ in range(3)] +for _ in range(N): +    b = int(eval(input())) +    for i in range(3): +        for j in range(3): +            if A[i][j] == b: +                B[i][j] = 1 +flag = 0 -    bng = 1 -    for j in range(3): -        if A[i][j] in B: -            continue -        else: -            bng = 0 -            break -    if bng == 1: +    if sum(B[i]) == 3: +        flag = 1 -if bng == 1: +for j in range(3): +    cnt = 0 +    for i in range(3): +        cnt += B[i][j] +    if cnt == 3: +        flag = 1 +        break +if B[0][0] + B[1][1] + B[2][2] == 3: +    flag = 1 +if B[2][0] + B[1][1] + B[0][2] == 3: +    flag = 1 +if flag == 1: -    for j in range(3): -        bng = 1 -        for i in range(3): -            if A[i][j] in B: -                continue -            else: -                bng = 0 -                break -        if bng == 1: -            break -    if bng == 1: -        print("Yes") -    else: -        if A[0][0] in B and A[1][1] in B and A[2][2] in B: -            print("Yes") -        elif A[0][2] in B and A[1][1] in B and A[2][0] in B: -            print("Yes") -        else: -            print("No") +    print("No")