import numpy as np

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



C = []

A = []

for _ in range(N):

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

    c = tmp[0]

    a = tmp[1:]

    C.append(c)

    A.append(a)

A = np.array(A)



ans = 10**18

for bit in range(1 << N):

    cost = 0

    V = np.array([0] * M)

    for i in range(N):

        if bit & 1 << i:

            cost += C[i]

            V += A[i]

    if np.all(V >= X):

        ans = min(ans, cost)

if ans == 10**18:

    print((-1))

else:

    print(ans)

import itertools as it

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

book = [[int(_) for _ in input().split()] for i in range(N)]

# print(f'book={book}')

combs = it.product([0, 1], repeat=N)

prices = []

for comb in combs:

    # print(comb)

    bag = [0] * (M + 1)

    for i in range(N):

        if comb[i] == 0:

            continue

        else:

            for j in range(M + 1):

                bag[j] += book[i][j]

    # print(f'bag={bag}')

    if min(bag[1:]) < X:

        continue

    else:

        prices.append(bag[0])

if len(prices) == 0:

    print((-1))

else:

    print((min(prices)))

import numpy as np

N, M, X = list(map(int, input().split()))
C = []
A = []
for _ in range(N):
    tmp = list(map(int, input().split()))
    c = tmp[0]
    a = tmp[1:]
    C.append(c)
    A.append(a)
A = np.array(A)
ans = 10**18
for bit in range(1 << N):
    cost = 0
    V = np.array([0] * M)
    for i in range(N):
        if bit & 1 << i:
            cost += C[i]
            V += A[i]
    if np.all(V >= X):
        ans = min(ans, cost)
if ans == 10**18:
    print((-1))
else:
    print(ans)

import itertools as it

N, M, X = list(map(int, input().split()))
book = [[int(_) for _ in input().split()] for i in range(N)]
# print(f'book={book}')
combs = it.product([0, 1], repeat=N)
prices = []
for comb in combs:
    # print(comb)
    bag = [0] * (M + 1)
    for i in range(N):
        if comb[i] == 0:
            continue
        else:
            for j in range(M + 1):
                bag[j] += book[i][j]
    # print(f'bag={bag}')
    if min(bag[1:]) < X:
        continue
    else:
        prices.append(bag[0])
if len(prices) == 0:
    print((-1))
else:
    print((min(prices)))

-import numpy as np +import itertools as it -C = [] -A = [] -for _ in range(N): -    tmp = list(map(int, input().split())) -    c = tmp[0] -    a = tmp[1:] -    C.append(c) -    A.append(a) -A = np.array(A) -ans = 10**18 -for bit in range(1 << N): -    cost = 0 -    V = np.array([0] * M) +book = [[int(_) for _ in input().split()] for i in range(N)] +# print(f'book={book}') +combs = it.product([0, 1], repeat=N) +prices = [] +for comb in combs: +    # print(comb) +    bag = [0] * (M + 1) -        if bit & 1 << i: -            cost += C[i] -            V += A[i] -    if np.all(V >= X): -        ans = min(ans, cost) -if ans == 10**18: +        if comb[i] == 0: +            continue +        else: +            for j in range(M + 1): +                bag[j] += book[i][j] +    # print(f'bag={bag}') +    if min(bag[1:]) < X: +        continue +    else: +        prices.append(bag[0]) +if len(prices) == 0: -    print(ans) +    print((min(prices)))