A=[]

for _ in range(3):

    A+=list(map(int,input().split()))



N=int(eval(input()))

for _ in range(N):

    b=int(eval(input()))

    if b in A:

        A[A.index(b)]=0



p=[

  (0,1,2),(3,4,5),(6,7,8),

  (0,3,6),(1,4,7),(2,5,8),

  (0,4,8),(2,4,6),

]



for i,j,k in p:

    if A[i]==A[j]==A[k]==0:

        print('Yes')

        break

else:

    print('No')

A=[]

for _ in range(3):

    A+=list(map(int,input().split()))



N=int(eval(input()))

for _ in range(N):

    b=int(eval(input()))

    if b in A:

        A[A.index(b)]=0



p=[

  (0,1,2),(3,4,5),(6,7,8),

  (0,3,6),(1,4,7),(2,5,8),

  (0,4,8),(2,4,6),

]



for i,j,k in p:

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

        print('Yes')

        break

else:

    print('No')

A = []
for _ in range(3):
    A += list(map(int, input().split()))
N = int(eval(input()))
for _ in range(N):
    b = int(eval(input()))
    if b in A:
        A[A.index(b)] = 0
p = [
    (0, 1, 2),
    (3, 4, 5),
    (6, 7, 8),
    (0, 3, 6),
    (1, 4, 7),
    (2, 5, 8),
    (0, 4, 8),
    (2, 4, 6),
]
for i, j, k in p:
    if A[i] == A[j] == A[k] == 0:
        print("Yes")
        break
else:
    print("No")

A = []
for _ in range(3):
    A += list(map(int, input().split()))
N = int(eval(input()))
for _ in range(N):
    b = int(eval(input()))
    if b in A:
        A[A.index(b)] = 0
p = [
    (0, 1, 2),
    (3, 4, 5),
    (6, 7, 8),
    (0, 3, 6),
    (1, 4, 7),
    (2, 5, 8),
    (0, 4, 8),
    (2, 4, 6),
]
for i, j, k in p:
    if A[i] == A[j] == A[k]:
        print("Yes")
        break
else:
    print("No")

-    if A[i] == A[j] == A[k] == 0: +    if A[i] == A[j] == A[k]: