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

n = int(eval(input()))

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

res = 'No'

for num in nums:

    for i in range(3):

        if num in bingo[i]:

            j = bingo[i].index(num)

            bingo[i][j] = 0

            if sum(bingo[i]) == 0 or sum([row[j] for row in bingo]) == 0:

                res = 'Yes'

            elif (i + j) % 2 == 0:

                if i + j == 2 and sum([bingo[0][2], bingo[1][1], bingo[2][0]]) == 0:

                    res = 'Yes'

                elif i == j and sum([bingo[0][0], bingo[1][1], bingo[2][2]]) == 0:

                    res = 'Yes'

            break

    if res == 'Yes':

        break

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

n = int(eval(input()))

for i in range(n):

    num = int(eval(input()))

    for j in range(3):

        for k in range(3):

            if bingo[j][k] == num:

                bingo[j][k] = 0

                break;

res = 'No'

for i in range(3):

    if bingo[i][0] == bingo[i][1] == bingo[i][2] == 0:

        res = 'Yes'

        break

    elif bingo[0][i] == bingo[1][i] == bingo[2][i] == 0:

        res = 'Yes'

        break

if bingo[0][2] == bingo[1][1] == bingo[2][0] == 0:

    res = 'Yes'

elif bingo[0][0] == bingo[1][1] == bingo[2][2] == 0:

    res = 'Yes'

print(res)
bingo = [list(map(int, input().split())) for i in range(3)]
n = int(eval(input()))
nums = [int(eval(input())) for i in range(n)]
res = "No"
for num in nums:
    for i in range(3):
        if num in bingo[i]:
            j = bingo[i].index(num)
            bingo[i][j] = 0
            if sum(bingo[i]) == 0 or sum([row[j] for row in bingo]) == 0:
                res = "Yes"
            elif (i + j) % 2 == 0:
                if i + j == 2 and sum([bingo[0][2], bingo[1][1], bingo[2][0]]) == 0:
                    res = "Yes"
                elif i == j and sum([bingo[0][0], bingo[1][1], bingo[2][2]]) == 0:
                    res = "Yes"
            break
    if res == "Yes":
        break
print(res)

bingo = [list(map(int, input().split())) for i in range(3)]
n = int(eval(input()))
for i in range(n):
    num = int(eval(input()))
    for j in range(3):
        for k in range(3):
            if bingo[j][k] == num:
                bingo[j][k] = 0
                break
res = "No"
for i in range(3):
    if bingo[i][0] == bingo[i][1] == bingo[i][2] == 0:
        res = "Yes"
        break
    elif bingo[0][i] == bingo[1][i] == bingo[2][i] == 0:
        res = "Yes"
        break
if bingo[0][2] == bingo[1][1] == bingo[2][0] == 0:
    res = "Yes"
elif bingo[0][0] == bingo[1][1] == bingo[2][2] == 0:
    res = "Yes"
print(res)

-nums = [int(eval(input())) for i in range(n)] +for i in range(n): +    num = int(eval(input())) +    for j in range(3): +        for k in range(3): +            if bingo[j][k] == num: +                bingo[j][k] = 0 +                break -for num in nums: -    for i in range(3): -        if num in bingo[i]: -            j = bingo[i].index(num) -            bingo[i][j] = 0 -            if sum(bingo[i]) == 0 or sum([row[j] for row in bingo]) == 0: -                res = "Yes" -            elif (i + j) % 2 == 0: -                if i + j == 2 and sum([bingo[0][2], bingo[1][1], bingo[2][0]]) == 0: -                    res = "Yes" -                elif i == j and sum([bingo[0][0], bingo[1][1], bingo[2][2]]) == 0: -                    res = "Yes" -            break -    if res == "Yes": +for i in range(3): +    if bingo[i][0] == bingo[i][1] == bingo[i][2] == 0: +        res = "Yes" +    elif bingo[0][i] == bingo[1][i] == bingo[2][i] == 0: +        res = "Yes" +        break +if bingo[0][2] == bingo[1][1] == bingo[2][0] == 0: +    res = "Yes" +elif bingo[0][0] == bingo[1][1] == bingo[2][2] == 0: +    res = "Yes"