import numpy as np



N, M, X = list(map(int, input().split()))



C = [0]*N

A = np.zeros((N, M), int)

for i in range(N):

    C[i], *A[i] = list(map(int, input().split()))



ans = 12345678

for bit in range(1, 2**N):

    c = [C[i] for i in range(N) if bit & (1 << i)]

    a = [A[i] for i in range(N) if bit & (1 << i)]

    a = np.array(a)



    if all(a.sum(0) >= X):

        ans = min(ans, sum(c))



print((-1 if ans == 12345678 else ans))

(N, M, X), *T = [[*list(map(int, line.split()))] for line in open(0)]



ans = 12345678

for bit in range(1, 2**N):

    t = [T[i] for i in range(N) if bit & (1 << i)]

    c, *a = list(map(sum, list(zip(*t))))

    if all(e >= X for e in a):

        ans = min(ans, c)



print((-1 if ans == 12345678 else ans))

import numpy as np

N, M, X = list(map(int, input().split()))
C = [0] * N
A = np.zeros((N, M), int)
for i in range(N):
    C[i], *A[i] = list(map(int, input().split()))
ans = 12345678
for bit in range(1, 2**N):
    c = [C[i] for i in range(N) if bit & (1 << i)]
    a = [A[i] for i in range(N) if bit & (1 << i)]
    a = np.array(a)
    if all(a.sum(0) >= X):
        ans = min(ans, sum(c))
print((-1 if ans == 12345678 else ans))

(N, M, X), *T = [[*list(map(int, line.split()))] for line in open(0)]
ans = 12345678
for bit in range(1, 2**N):
    t = [T[i] for i in range(N) if bit & (1 << i)]
    c, *a = list(map(sum, list(zip(*t))))
    if all(e >= X for e in a):
        ans = min(ans, c)
print((-1 if ans == 12345678 else ans))

-import numpy as np - -N, M, X = list(map(int, input().split())) -C = [0] * N -A = np.zeros((N, M), int) -for i in range(N): -    C[i], *A[i] = list(map(int, input().split())) +(N, M, X), *T = [[*list(map(int, line.split()))] for line in open(0)] -    c = [C[i] for i in range(N) if bit & (1 << i)] -    a = [A[i] for i in range(N) if bit & (1 << i)] -    a = np.array(a) -    if all(a.sum(0) >= X): -        ans = min(ans, sum(c)) +    t = [T[i] for i in range(N) if bit & (1 << i)] +    c, *a = list(map(sum, list(zip(*t)))) +    if all(e >= X for e in a): +        ans = min(ans, c)