n,m,c = list(map(int,input().split()))

b = list(map(int,input().split()))

cnt = 0

for i in range(n):

    a = list(map(int,input().split()))

    t = c

    for j in range(m):

        t+= a[j]*b[j]

    if t>0:

        cnt+=1

print(cnt)
n,m,c = list(map(int, input().split()))

ans = 0

b = list(map(int,input().split()))

for i in range(n):

    t = c

    a = list(map(int,input().split()))

    for j in range(m):

        t+=a[j]*b[j]

    if t>0:

        ans+=1

print(ans)
n, m, c = list(map(int, input().split()))
b = list(map(int, input().split()))
cnt = 0
for i in range(n):
    a = list(map(int, input().split()))
    t = c
    for j in range(m):
        t += a[j] * b[j]
    if t > 0:
        cnt += 1
print(cnt)

n, m, c = list(map(int, input().split()))
ans = 0
b = list(map(int, input().split()))
for i in range(n):
    t = c
    a = list(map(int, input().split()))
    for j in range(m):
        t += a[j] * b[j]
    if t > 0:
        ans += 1
print(ans)

+ans = 0 -cnt = 0 +    t = c -    t = c -        cnt += 1 -print(cnt) +        ans += 1 +print(ans)