import numpy as np

import itertools

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

CA=[]

D=[]



for n in range(N):

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

  CA.append(arr)

CA=np.array(CA)



v=list(itertools.product([0,1], repeat=N))



for v_ in v:

  SUM=np.zeros(M+1)

  for n in range(N):

    if v_[n]==1:

      SUM = SUM+CA[n]

  D.append(list(SUM))



key=[]

value=[]

  

for d in D:

  key.append(d[0])

  value.append(d[1:])

  

dict = dict(list(zip(key,value)))

dict_sorted = sorted(list(dict.items()), key=lambda x:x[0])





for d in dict_sorted:

  if all([i>=X  for i in d[1]]):

    print((int(d[0])))

    exit()



print((-1))

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

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

  

ans=9999999999



for i in range(2**N):

  cost=0

  C=[0]*M

  for n in range(N):

    #右にずらして一桁目が1かどうかを判定

    if (i>>n) &1:

      cost += arr[n][0]

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

        C[j-1] += arr[n][j]

  if min(C)>=X:

    ans=min(ans, cost)

    

if ans ==  9999999999:

  print((-1))

else:

  print(ans)
import numpy as np
import itertools

N, M, X = list(map(int, input().split()))
CA = []
D = []
for n in range(N):
    arr = list(map(int, input().split()))
    CA.append(arr)
CA = np.array(CA)
v = list(itertools.product([0, 1], repeat=N))
for v_ in v:
    SUM = np.zeros(M + 1)
    for n in range(N):
        if v_[n] == 1:
            SUM = SUM + CA[n]
    D.append(list(SUM))
key = []
value = []
for d in D:
    key.append(d[0])
    value.append(d[1:])
dict = dict(list(zip(key, value)))
dict_sorted = sorted(list(dict.items()), key=lambda x: x[0])
for d in dict_sorted:
    if all([i >= X for i in d[1]]):
        print((int(d[0])))
        exit()
print((-1))

N, M, X = list(map(int, input().split()))
arr = [list(map(int, input().split())) for _ in range(N)]
ans = 9999999999
for i in range(2**N):
    cost = 0
    C = [0] * M
    for n in range(N):
        # 右にずらして一桁目が1かどうかを判定
        if (i >> n) & 1:
            cost += arr[n][0]
            for j in range(1, M + 1):
                C[j - 1] += arr[n][j]
    if min(C) >= X:
        ans = min(ans, cost)
if ans == 9999999999:
    print((-1))
else:
    print(ans)

-import numpy as np -import itertools - -CA = [] -D = [] -for n in range(N): -    arr = list(map(int, input().split())) -    CA.append(arr) -CA = np.array(CA) -v = list(itertools.product([0, 1], repeat=N)) -for v_ in v: -    SUM = np.zeros(M + 1) +arr = [list(map(int, input().split())) for _ in range(N)] +ans = 9999999999 +for i in range(2**N): +    cost = 0 +    C = [0] * M -        if v_[n] == 1: -            SUM = SUM + CA[n] -    D.append(list(SUM)) -key = [] -value = [] -for d in D: -    key.append(d[0]) -    value.append(d[1:]) -dict = dict(list(zip(key, value))) -dict_sorted = sorted(list(dict.items()), key=lambda x: x[0]) -for d in dict_sorted: -    if all([i >= X for i in d[1]]): -        print((int(d[0]))) -        exit() -print((-1)) +        # 右にずらして一桁目が1かどうかを判定 +        if (i >> n) & 1: +            cost += arr[n][0] +            for j in range(1, M + 1): +                C[j - 1] += arr[n][j] +    if min(C) >= X: +        ans = min(ans, cost) +if ans == 9999999999: +    print((-1)) +else: +    print(ans)