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

n = int(input())

for i in range(n):

    num = int(input())

    for i in range(3):

        for j in range(3):

            if card[i][j] == num:

                card[i][j] = 0

for i in range(3):

    if  (card[0][i] == 0 and card[1][i] == 0 and card[2][i] == 0) or\

        (card[i][0] == 0 and card[i][1] == 0 and card[i][2] == 0):

        print("Yes")

        exit()

if  (card[0][0] == 0 and card[1][1] == 0 and card[2][2] == 0) or\

    (card[0][2] == 0 and card[1][1] == 0 and card[2][0] == 0):

    print("Yes")

    exit()

print("No")

import sys

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

N = int(input())

for _ in range(N):

    cmd = int(input())

    for i in range(3):

        for j in range(3):

            if table[i][j] == cmd:

                table[i][j] = -1

                break

for i in range(3):

    if (table[i][0]==-1 and table[i][1]==-1 and table[i][2]==-1) or \

        (table[0][i]==-1 and table[1][i]==-1 and table[2][i]==-1):

        print("Yes")

        sys.exit()

if (table[0][0]==-1 and table[1][1]==-1 and table[2][2]==-1) or \

    (table[0][2]==-1 and table[1][1]==-1 and table[2][0]==-1):

    print("Yes")

    sys.exit()

print("No")

card = [list(map(int, input().split())) for i in range(3)]
n = int(input())
for i in range(n):
    num = int(input())
    for i in range(3):
        for j in range(3):
            if card[i][j] == num:
                card[i][j] = 0
for i in range(3):
    if (card[0][i] == 0 and card[1][i] == 0 and card[2][i] == 0) or (
        card[i][0] == 0 and card[i][1] == 0 and card[i][2] == 0
    ):
        print("Yes")
        exit()
if (card[0][0] == 0 and card[1][1] == 0 and card[2][2] == 0) or (
    card[0][2] == 0 and card[1][1] == 0 and card[2][0] == 0
):
    print("Yes")
    exit()
print("No")

import sys

table = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
for _ in range(N):
    cmd = int(input())
    for i in range(3):
        for j in range(3):
            if table[i][j] == cmd:
                table[i][j] = -1
                break
for i in range(3):
    if (table[i][0] == -1 and table[i][1] == -1 and table[i][2] == -1) or (
        table[0][i] == -1 and table[1][i] == -1 and table[2][i] == -1
    ):
        print("Yes")
        sys.exit()
if (table[0][0] == -1 and table[1][1] == -1 and table[2][2] == -1) or (
    table[0][2] == -1 and table[1][1] == -1 and table[2][0] == -1
):
    print("Yes")
    sys.exit()
print("No")

-card = [list(map(int, input().split())) for i in range(3)] -n = int(input()) -for i in range(n): -    num = int(input()) +import sys + +table = [list(map(int, input().split())) for _ in range(3)] +N = int(input()) +for _ in range(N): +    cmd = int(input()) -            if card[i][j] == num: -                card[i][j] = 0 +            if table[i][j] == cmd: +                table[i][j] = -1 +                break -    if (card[0][i] == 0 and card[1][i] == 0 and card[2][i] == 0) or ( -        card[i][0] == 0 and card[i][1] == 0 and card[i][2] == 0 +    if (table[i][0] == -1 and table[i][1] == -1 and table[i][2] == -1) or ( +        table[0][i] == -1 and table[1][i] == -1 and table[2][i] == -1 -        exit() -if (card[0][0] == 0 and card[1][1] == 0 and card[2][2] == 0) or ( -    card[0][2] == 0 and card[1][1] == 0 and card[2][0] == 0 +        sys.exit() +if (table[0][0] == -1 and table[1][1] == -1 and table[2][2] == -1) or ( +    table[0][2] == -1 and table[1][1] == -1 and table[2][0] == -1 -    exit() +    sys.exit()