bin = []

for i in range(3):

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

bin = sum(bin, [])

N = int(input())

bingo = [False for _ in range(9)]

for _ in range(N):

  b = int(input())

  if b in bin:

    bingo[bin.index(b)] = True

if (bingo[0] and bingo[1] and bingo[2]) or (bingo[3] and bingo[4] and bingo[5]) or \

   (bingo[6] and bingo[7] and bingo[8]) or (bingo[0] and bingo[3] and bingo[6]) or \

   (bingo[1] and bingo[4] and bingo[7]) or (bingo[2] and bingo[5] and bingo[8]) or \

   (bingo[0] and bingo[4] and bingo[8]) or (bingo[2] and bingo[4] and bingo[6]):

  print("Yes")

else:

  print("No")

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

N = int(input())

for _ in range(N):

  b = int(input())

  for i in range(3):

    for j in range(3):

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

        bingo[i][j] = 0



ans = "No"

for k in range(3):

  if bingo[k][0] == bingo[k][1] == bingo[k][2] or \

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

    ans = "Yes"

    break

if bingo[0][0] == bingo[1][1] == bingo[2][2] or \

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

  ans = "Yes"

print(ans)

bin = []
for i in range(3):
    bin.append(list(map(int, input().split())))
bin = sum(bin, [])
N = int(input())
bingo = [False for _ in range(9)]
for _ in range(N):
    b = int(input())
    if b in bin:
        bingo[bin.index(b)] = True
if (
    (bingo[0] and bingo[1] and bingo[2])
    or (bingo[3] and bingo[4] and bingo[5])
    or (bingo[6] and bingo[7] and bingo[8])
    or (bingo[0] and bingo[3] and bingo[6])
    or (bingo[1] and bingo[4] and bingo[7])
    or (bingo[2] and bingo[5] and bingo[8])
    or (bingo[0] and bingo[4] and bingo[8])
    or (bingo[2] and bingo[4] and bingo[6])
):
    print("Yes")
else:
    print("No")

bingo = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
for _ in range(N):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if bingo[i][j] == b:
                bingo[i][j] = 0
ans = "No"
for k in range(3):
    if (
        bingo[k][0] == bingo[k][1] == bingo[k][2]
        or bingo[0][k] == bingo[1][k] == bingo[2][k]
    ):
        ans = "Yes"
        break
if (
    bingo[0][0] == bingo[1][1] == bingo[2][2]
    or bingo[0][2] == bingo[1][1] == bingo[2][0]
):
    ans = "Yes"
print(ans)

-bin = [] -for i in range(3): -    bin.append(list(map(int, input().split()))) -bin = sum(bin, []) +bingo = [list(map(int, input().split())) for _ in range(3)] -bingo = [False for _ in range(9)] -    if b in bin: -        bingo[bin.index(b)] = True +    for i in range(3): +        for j in range(3): +            if bingo[i][j] == b: +                bingo[i][j] = 0 +ans = "No" +for k in range(3): +    if ( +        bingo[k][0] == bingo[k][1] == bingo[k][2] +        or bingo[0][k] == bingo[1][k] == bingo[2][k] +    ): +        ans = "Yes" +        break -    (bingo[0] and bingo[1] and bingo[2]) -    or (bingo[3] and bingo[4] and bingo[5]) -    or (bingo[6] and bingo[7] and bingo[8]) -    or (bingo[0] and bingo[3] and bingo[6]) -    or (bingo[1] and bingo[4] and bingo[7]) -    or (bingo[2] and bingo[5] and bingo[8]) -    or (bingo[0] and bingo[4] and bingo[8]) -    or (bingo[2] and bingo[4] and bingo[6]) +    bingo[0][0] == bingo[1][1] == bingo[2][2] +    or bingo[0][2] == bingo[1][1] == bingo[2][0] -    print("Yes") -else: -    print("No") +    ans = "Yes" +print(ans)