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

C = []

M = []



for _ in range(n):

    c, *mi = list(map(int, input().split()))

    C.append(c)

    M.append(mi)



res = 10**10



for i in range(1 << n):

    tmp = 0

    cnt = [0] * m

    for j in range(n):

        if (i >> j) & 1 == 1:

            tmp += C[j]

            for k in range(m):

                cnt[k] += M[j][k]

    if min(cnt) >= x:

        res = min(res, tmp)



if res == 10**10:

    print((-1))

else:

    print(res)

from itertools import product



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

C = []

M = []



for _ in range(n):

    c, *mi = list(map(int, input().split()))

    C.append(c)

    M.append(mi)



sta = list(product((0, 1), repeat=n))

res = 10**10



for k in sta:

    tmp = 0

    cnt = [0] * m

    for j in range(n):

        if k[j] == 1:

            tmp += C[j]

            for l in range(m):

                cnt[l] += M[j][l]

    if min(cnt) >= x:

        res = min(res, tmp)



if res == 10**10:

    print((-1))

else:

    print(res)

n, m, x = list(map(int, input().split()))
C = []
M = []
for _ in range(n):
    c, *mi = list(map(int, input().split()))
    C.append(c)
    M.append(mi)
res = 10**10
for i in range(1 << n):
    tmp = 0
    cnt = [0] * m
    for j in range(n):
        if (i >> j) & 1 == 1:
            tmp += C[j]
            for k in range(m):
                cnt[k] += M[j][k]
    if min(cnt) >= x:
        res = min(res, tmp)
if res == 10**10:
    print((-1))
else:
    print(res)

from itertools import product

n, m, x = list(map(int, input().split()))
C = []
M = []
for _ in range(n):
    c, *mi = list(map(int, input().split()))
    C.append(c)
    M.append(mi)
sta = list(product((0, 1), repeat=n))
res = 10**10
for k in sta:
    tmp = 0
    cnt = [0] * m
    for j in range(n):
        if k[j] == 1:
            tmp += C[j]
            for l in range(m):
                cnt[l] += M[j][l]
    if min(cnt) >= x:
        res = min(res, tmp)
if res == 10**10:
    print((-1))
else:
    print(res)

+from itertools import product + +sta = list(product((0, 1), repeat=n)) -for i in range(1 << n): +for k in sta: -        if (i >> j) & 1 == 1: +        if k[j] == 1: -            for k in range(m): -                cnt[k] += M[j][k] +            for l in range(m): +                cnt[l] += M[j][l]