import itertools

import numpy as np

 

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

ca = ([list(map(int,input().split())) for _ in range(N)])

ca = np.array(ca)

sumX = sum(ca)[1:]

sumcos = sum(ca)[0]

cost = sumcos

if sum(sumX>=X)<M:

    print((-1))

else:

    for j in range(1,N+1):

        for a in itertools.combinations(list(range(1,N+1)),j):       

            x = sum(ca)[1:]

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

            c = sumcos

            for i in range(len(a)):

                x -= ca[a[i]-1][1:]

                c -= ca[a[i]-1][0]

                if sum(x>=X)<M:

                    break

                else:

                    cost = min(c,cost)

    print(cost)

import sys

import numpy as np

input = sys.stdin.readline



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

CA = [ list(map(int,input().split())) for _ in range(N)]

bit = 2**N

cost = float('inf')



for bi in range(1,bit):

    tmp=[]

    for i in range(N):

        if bi & 1<<i:

            tmp.append(CA[i-1])

    tmp = np.array(tmp)        

    a = sum(tmp)

    if all( [a[j]>=X for j in range(1,M+1)]):

        cost = min(cost,a[0])

print(( -1 if cost == float('inf') else cost))

import itertools
import numpy as np

N, M, X = list(map(int, input().split()))
ca = [list(map(int, input().split())) for _ in range(N)]
ca = np.array(ca)
sumX = sum(ca)[1:]
sumcos = sum(ca)[0]
cost = sumcos
if sum(sumX >= X) < M:
    print((-1))
else:
    for j in range(1, N + 1):
        for a in itertools.combinations(list(range(1, N + 1)), j):
            x = sum(ca)[1:]
            fx = np.array([0] * M)
            c = sumcos
            for i in range(len(a)):
                x -= ca[a[i] - 1][1:]
                c -= ca[a[i] - 1][0]
                if sum(x >= X) < M:
                    break
                else:
                    cost = min(c, cost)
    print(cost)

import sys
import numpy as np

input = sys.stdin.readline
N, M, X = list(map(int, input().split()))
CA = [list(map(int, input().split())) for _ in range(N)]
bit = 2**N
cost = float("inf")
for bi in range(1, bit):
    tmp = []
    for i in range(N):
        if bi & 1 << i:
            tmp.append(CA[i - 1])
    tmp = np.array(tmp)
    a = sum(tmp)
    if all([a[j] >= X for j in range(1, M + 1)]):
        cost = min(cost, a[0])
print((-1 if cost == float("inf") else cost))

-import itertools +import sys +input = sys.stdin.readline -ca = [list(map(int, input().split())) for _ in range(N)] -ca = np.array(ca) -sumX = sum(ca)[1:] -sumcos = sum(ca)[0] -cost = sumcos -if sum(sumX >= X) < M: -    print((-1)) -else: -    for j in range(1, N + 1): -        for a in itertools.combinations(list(range(1, N + 1)), j): -            x = sum(ca)[1:] -            fx = np.array([0] * M) -            c = sumcos -            for i in range(len(a)): -                x -= ca[a[i] - 1][1:] -                c -= ca[a[i] - 1][0] -                if sum(x >= X) < M: -                    break -                else: -                    cost = min(c, cost) -    print(cost) +CA = [list(map(int, input().split())) for _ in range(N)] +bit = 2**N +cost = float("inf") +for bi in range(1, bit): +    tmp = [] +    for i in range(N): +        if bi & 1 << i: +            tmp.append(CA[i - 1]) +    tmp = np.array(tmp) +    a = sum(tmp) +    if all([a[j] >= X for j in range(1, M + 1)]): +        cost = min(cost, a[0]) +print((-1 if cost == float("inf") else cost))