Takahashi, who is a novice in competitive programming, wants to learn M algorithms.
Initially, his understanding level of each of the M algorithms is 0.
Takahashi is visiting a bookstore, where he finds N books on algorithms.
The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M).
There is no other way to increase the understanding levels of the algorithms.
Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it.



Difficulty: introductory

Starter code:

Solutions:
N, M, X = list(map(int, input().split()))
A = [0]*N

for i in range(N):
    A[i] = list(map(int, input().split()))

min_sump = -1
for i in range(2**(N+1)):
    sump = 0
    sume = [0]*M
    for j in range(N):
        ns = "0" + str(N) +"b"
        bi = format(i,ns)
        if bi[-1-j] == "1":
            sump += A[j][0]
            sume = list(map(sum, zip(sume, A[j][1:])))
    if all([i >= X for i in sume]):
        if min_sump == -1:
            min_sump = sump
        else:
            min_sump = min(min_sump,sump)

print(min_sump)

N, M, X = [int(i) for i in input().split()]
CA = []
for i in range(N):
    CA.append([int(j) for j in input().split()])
#print(CA)
mcost = 10**10


for i in range(2**N):
    learn = [0]*M
    cost = 0
    bn = str(bin(i))[2:].zfill(N)
    #print(bn)
    for j,b in enumerate(bn):
        if b == "1":
            cost += CA[j][0]
            for m in range(M):
                learn[m] += CA[j][m+1]
                
    learn.sort()
    #print(learn)
    if learn[0] >= X:
        mcost = min(mcost, cost)

if mcost == 10**10:
    mcost = -1

print(mcost)

n, m, x = map(int, input().split())
inp=[]

# 入力をすべて受け取る
for i in range(n):
  tmp = list(map(int, input().split()))
  inp.append(tmp)

# bit全探索を行うための箱づくり
sum = 0
min = 10**10
for i in range(2**n):
  tmp = [0]*m
  flg = 0
  
  # ある買う買わないのケースに対して、フラグが立ってたらスキルポイントを増やす
  for j in range(n):
    if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
      sum += inp[j][0]
      for k in range(1,m+1):
        #print(n,j, k, tmp, inp)
        tmp[k-1] += inp[j][k]
  for ii, k in enumerate(tmp):
    if k < x: # x未満ならflgをたててNGとする
      flg = 1
      break
  #print(tmp, flg)
  if sum < min and flg == 0: min = sum
  sum = 0
  
if min == 10**10: min = -1
print(min)

import numpy as np
N,M,X=map(int,input().split())
  
C=[[0 for i in range(M)] for j in range(N)]
for i in range(N):
    #C=[[0 for i in range(M)] for j in range(2**N)]
    C[i] = list(map(int, input().split()))
    #print(array)
    #np.insert(C[i],0,array)
D=np.array(C)
E=[0]*2**N

for i in range(2**N):
  c=format(i,'012b')
  for j in range(N):
    d=int(c[12-N+j])
    E[i]+=D[j]*int(d)
#print(E)

#for i in range(2**M):
if min(E[-1][1:M+1])<X:
  print(-1);return
    
Max=E[-1][0]+1
Min=Max
for i in range(2**N):
  if min(E[i][1:M+1])>=X:
    if Min>E[i][0]:Min=E[i][0]
    continue
  else:E[i][0]=Max
#print(E)
print(Min)
return

N, M, X = list(map(int, input().split()))
C = []
D = []
for _ in range(N):
    line = list(map(int, input().split()))
    C.append(line[0])
    D.append(line[1:])

res = []
ans = []
for i in range(2 ** N):
    score = [0 for _ in range(M)]
    price = 0
    for j in range(N):  # このループが一番のポイント
        if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
            price += C[j]
            for d in range(M):
                score[d - 1] += D[j][d]
    ifPassed = 1
    for m in range(M):
        if not score[m] >= X:
            ifPassed = 0
            break
    if ifPassed:
        ans.append(price)
if not ans:
    print((-1))
else:
    print((min(ans)))


n,m,x = map(int,input().split())
c = [list(map(int,input().split())) for _ in range(n)]
ans = []
#n冊の本において買うか買わないかの2通りなので2**n
for i in range(2**n):
    #リストの中身は値段1と理解度m個
    a = [0]*(m+1)
    com = i
    for j in range(n):
        if com >= (2**(n-j-1)):
            com -= 2**(n-j-1)
            for k in range(m+1):
                a[k] += c[j][k]
    price = a[0]
    del a[0]
    if all(a[j]>=x for j in range(m)):
        #print(price)
        ans.append(price)
if len(ans) == 0:
    print(-1)
else:
    print(min(ans))

from itertools import combinations
n,m,x = map(int, input().split())
ca = [list(map(int, input().split())) for _ in range(n)]

ans = float("inf")
for i in range(1, n+1):
  for i1 in combinations(ca, i):
    nums = [0]*(m+1)
    for i2 in i1:
      for i3 in range(m+1): nums[i3] += i2[i3]
    if min(nums[1:]) >= x:
      if nums[0] < ans: ans = nums[0]
if ans == float("inf"): print(-1)
else: print(ans)

N,M,X=[int(s) for s in input().split()]
Book=[[int(s) for s in input().split()] for _ in range(N)]
INF=10**7

ans=set()
ans.add(INF)

for n in range(2**N):
  #Bit全探索
  Xls=[0 for i in range(M)]
  cost=0
  for i in range(N):
    if ((n>>i)&1)==1:
      cost+=Book[i][0]
      for b in range(M):
        Xls[b]+=Book[i][b+1]
    if min(Xls)>=X:
      ans.add(cost)
if min(ans)==INF:
  print(-1)
else:
  print(min(ans))

N, M, X = map(int, input().split())
item = []
ans = []
for i in range(N):
  item.append(list(map(int, input().split())))
for i in range(2**N):
  bag = []
  money = 0
  for j in range(N):
    if ((i>>j) & 1):
      bag.append(item[j])
  if bag == []:
    continue
  total = [0] * M
  for k in bag:
    money += k[0]
    for l in range(1, M+1):
      total[l-1] += k[l]
  if min(total) >= X:
    ans.append(money)
if ans == []:
  print(-1)
else:
  print(min(ans))

def main():
    N,M,X = list(map(int,input().split()))
    ca = [list(map(int,input().split())) for _ in range(N)]
    
    mincost = 12*10**5
    flag = 0
    for i in range(1,2**N):
        lev = [0] * M
        cost = 0
        a = list((("0"*N)+bin(i)[2:])[-N:])
        for j in range(N):
            if a[j] == "1":
                cost +=  ca[j][0]
                for k in range(M):
                    lev[k] += ca[j][k+1]
        if min(lev) >= X:
            mincost = min(mincost,cost)
            flag = 1
    if flag == 0:
        print((-1))
    else:
        print(mincost)
main()


from itertools import product

n,m,x = list(map(int, input().split()))
book = []
for i in range(n):
    book.append(list(map(int, input().split())))

ans = 10 ** 5 * n
flag = False
for i in product([0,1], repeat=n):
    price = 0
    skill = [0] * m
    for index_, bit in enumerate(i):
        if bit:
            for j in range(m):
                skill[j] += book[index_][ j + 1]
            price += book[index_][0]
    if all(v >= x for v in skill):
        ans = min(ans, price)
        flag = True
if flag:
    print(ans)
else:
    print(-1)

#!/usr/bin/env python3

#import
#import math
#import numpy as np
#= int(input())
#= input()
N, M, X = list(map(int, input().split()))
CA = [list(map(int, input().split())) for _ in range(N)]
MAX_ANS = 10**9
ans = MAX_ANS

for i in range(2 ** N):
    buy = []
    for j in range(N):
        if (i >> j) & 1:
            buy.append(j)

    understand = [0] * (M + 1)
    money = 0
    for b in buy:
        money += CA[b][0]
        for i in range(1, M + 1):
            understand[i] += CA[b][i]

    isok = True
    for i in range(1, M + 1):
        if understand[i] < X:
            isok = False
            break

    if isok:
        ans = min(ans, money)

if ans == MAX_ANS:
    print((-1))
else:
    print(ans)


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


def num2bi(num):
    l = [0] * N
    for i in range(N):
        if num >= 2 ** (N - 1 - i):
            num -= 2 ** (N - 1 - i)
            l[i] = 1
    return l


SUM = [0] * M
A = [[0] * M for _ in range(N)]
C = []
for i in range(N):
    a = list(map(int, input().split()))
    for j in range(M):
        SUM[j] += a[j + 1]
        A[i][j] = a[j + 1]
    C.append(a[0])

ans = sum(C)
if min(SUM) < X:
    ans = -1
else:
    for num in range(2 ** N):
        SUM = [0] * M
        tmp = 0
        for i in range(N):
            if num2bi(num)[i] == 1:
                for j in range(M):
                    SUM[j] += A[i][j]
                tmp += C[i]
        if min(SUM) >= X:
            ans = min(ans, tmp)

print(ans)

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

sum = 0
for i in range(n):
    sum += ca[i][0]
ans = sum + 1

for i in range(2**n) :
    cnt = 0
    a = [0]*m
    for j in range(n) :
        if ((i>>j)&1) :
            for k in range(m) :
                a[k] += ca[j][k+1]
            cnt += ca[j][0]
    if cnt > 0 and min(a) >= x :
        ans = min(cnt,ans)

if ans == sum + 1 :
    print((-1))
else :
    print(ans)


from collections import deque
from copy import deepcopy
n, m, x = list(map(int, input().split()))
books = [tuple(map(int, input().split())) for _ in range(n)]
D = deque()
D.append((-1, 0, [0 for _ in range(m)]))
ans = 10 ** 9

while D:
    num, money, skill = D.popleft()
    if num == n - 1:
        if all(s >= x for s in skill):
            ans = min(ans, money)
    else:
        num += 1
        D.append((num, money, skill))
        book = books[num]
        skill = deepcopy(skill)
        money += book[0]
        for i, b in enumerate(book[1:]):
            skill[i] += b
        D.append((num, money, skill))

print((ans if ans != 10**9 else -1))


import itertools
n, m, x = map(int, input().split())
books = []
for i in range(n):
  ins = list(map(int, input().split()))
  books.append({"c": ins[0], "a": ins[1: m+1]})
ans = float('inf')
for i in range(1, n+1):
  book_list = list(itertools.combinations(list(range(n)), i))
  for lis in book_list:
    cost_sum = 0
    a_sum = [0] * m
    ok = 0
    ok_list = [False] * m
    for j in lis:
      cost_sum += books[j]['c']
      for k in range(m):
        a_sum[k] += books[j]['a'][k]
        if not ok_list[k] and a_sum[k] >= x:
          ok += 1
          ok_list[k] = True
    if ok == m and ans > cost_sum:
      ans = cost_sum
if ans == float('inf'):
  print(-1)
else:
  print(ans)

n, m, x = map(int, input().split())
c = []
a = []
for i in range(n):
  inp = list(map(int, input().split()))
  c_, a_ = inp[0], inp[1:]
  c.append(c_)
  a.append(a_)

ans = float('inf')
for bit in range(1<<n):
  cost = 0
  skill = [0]*m
  for i in range(n):
    if bit & 1<<i:
      cost += c[i]
      for j in range(m):
        skill[j] += a[i][j]
  if min(skill) >= x:
    ans = min(ans, cost)

if ans == float('inf'):
  print(-1)
else:
  print(ans)

N,M,X = map(int,input().split())
C = []
A = []
for i in range(N):
    a = [int(i) for i in input().split()]
    C.append(a[0])
    del a[0]
    A.append(a)
ans = M * (10**5) + 1
for i in range(2**N):
    bi = format(i,"b")
    bistr = str(bi)
    P = ["0"]*N
    Q = [0]*M
    m = 0
    for j in range(len(bistr)):
        P[-1-j] = bistr[-1-j]
    for j in range(N):
        if(P[j] == "1"):
            m += C[j]
            for k in range(M):
                Q[k] += A[j][k]
    count = 0
    for j in range(M):
        if(Q[j] >= X):
            count += 1
        if(count >= M):
            ans = min(ans,m)
if(ans >= M * (10**5) + 1):
    print(-1)
    return
print(ans)

import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
import numpy as np
def main():
    n, m, x = list(map(int, input().split()))
    data = np.array(read().split(), np.int64)
    data = data.reshape(n, -1) # dataをn行に整形
    cost_per_cost = data[:, 0] # data全行の0列
    effect_per_book = data[:, 1:]

    costs = np.zeros(2**n, np.int64)
    # ability 行数：2**n(本の組み合わせパターン), 列数：アルゴリズムの数
    ability = np.zeros((2**n, m), np.int64)
    for i in range(n):
        costs[1<<i:1<<(i+1)] = costs[:1<<i] + cost_per_cost[i]
        ability[1<<i:1<<(i+1)] = ability[:1<<i] + effect_per_book[i]
    ok = np.all(ability >= x, axis=1)
    res = costs[ok]
    if len(res) == 0:
        print((-1))
    else:
        print((res.min()))

def __starting_point():
    main()


__starting_point()

from itertools import product

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

cost = -1
for cand in product((0, 1), repeat=n):
  tmp = 0
  scores = [0] * m
  for bought, ca in zip(cand, CA):
    if not bought:
      continue
    for i in range(1, m + 1):
      scores[i - 1] += ca[i]
    tmp +=  ca[0]
  if min(scores) >= x and (cost == -1 or tmp < cost):
    cost = tmp
print(cost)

N,M,X = list(map(int,input().split()))
B=[0]*N
for i in range(N):
    B[i]=list(map(int, input().strip().split()))

x=N*10**10
sum_ok = N*10**10
unst =[0]*M
flg=0

def all0(v):
    return 0


for i in range(2**N):
    # print(bin(i))
    sum = 0
    unst = list(map(all0,unst))
    for j in range(N):
        if (i >> j) & 1 :
            # print(j)
            sum += B[j][0]
            # unst = list(map(lamda:x,x+B[j][]))
            for k in range(M):
                unst[k]+=B[j][k+1]
    # print(unst)
    # print("sum=",sum)
    if all(elem >= X for elem in unst):
        sum_ok = sum
        flg=1
    x=min(x,sum_ok)
    # print(x)
        
# print(unst)

if flg==0:
    print((-1))
else:
    print(x)
        
        


n, m, x = list(map(int, input().split()))
cl = list(list(map(int, input().split())) for _ in range(n))

ans = float('inf')
for i in range(2**n):
    tmp = [0]*m
    cost = 0
    for j in range(n):
        if (i >> j) & 1:
            for k in range(m):
                tmp[k] += cl[j][k+1]
            cost += cl[j][0]
    for t in tmp:
        if t < x:
            break
    else:
        ans = min(ans, cost)

if ans == float('inf'):
    print((-1))
else:
    print(ans)


n,m,x = map(int,input().split())
c = list(list(map(int,input().split())) for _ in range(n))
ans = 10**7
for i in range(1<<n):
    mokuhyo = [0]*m
    cost = 0
    for j in range(n):
        if i>>j&1:
            for r in range(m):
                mokuhyo[r] += c[j][r+1]
            cost += c[j][0]
    if all(k>=x for k in mokuhyo):
        ans = min(ans, cost)
print("-1" if ans == 10**7 else ans)        

N, M, X = list(map(int, input().split()))
C = []
A = []
for _ in range(N):
    l = list(map(int, input().split()))
    C.append(l[0])
    A.append(l[1:])

ans = -1
for i in range((1<<N)):
    u = [0] * M
    p = 0
    for j in range(N):
        if i & (1 << j):
            p += C[j]
            for k in range(M):
                u[k] += A[j][k]
    if min(u) >= X:
        if ans == -1 or ans > p:
            ans = p
print(ans)



N, M, X = [int(_) for _ in input().split()]
A = []
C = []
for _ in range(N):
    c, *a = [int(_) for _ in input().split()]
    A.append(tuple(a))
    C.append(c)

ans = 10 ** 10
for i in range(2 ** N):
    v = [0 for _ in range(M)]
    c = 0
    for j in range(N):
        if i & 1 << j:
            for k, a in enumerate(A[j]):
                v[k] += a
            c += C[j]
    if min(v) >= X:
        ans = min(ans, c)

if ans == 10 ** 10:
    print((-1))
else:
    print(ans)


import numpy as np


def main() -> None:
    n, m, x = list(map(int, input().split()))
    books = [tuple(map(int, input().split())) for _ in range(n)]

    is_able = False
    answer = float('inf')
    for i in range(2**n):
        money = 0
        skills = np.zeros(m)
        for j in range(n):
            if ((i >> j) & 1):
                money += books[j][0]
                skills += books[j][1:]
        if x <= skills.min():
            is_able = True
            answer = min(answer, money)

    print((answer if is_able else -1))
    return


def __starting_point():
    main()

__starting_point()

import numpy as np
n,m,x = list(map(int,input().split()))
c = []
a = []

for i in range(n):
  stdIn = list(map(int,input().split()))
  c.append(stdIn[0])
  a.append(stdIn[1:])
flag = 0
ans = sum(c)
for i in range(2**n):
  result = np.array([0]*m)
  price = 0
  for j in range(n):
    if((i>>j)&1):
      result += a[j]
      price += c[j]
  if (len(result[result<x])==0):
    ans = min(ans,price)
    flag = 1
print(ans if flag != 0 else -1)

n,m,x = map(int, input().split())
c = [list(map(int, input().split())) for _ in range(n)]
prices = []
for i in range(2**n):
  buy = [[] for _ in range(m+1)]
  for j in range(n):
    if ((i >> j) & 1):
      for k in range(m+1):
        buy[k].append(c[j][k])
  for k in range(1,m+1):
    if sum(buy[k]) < x:
      break
  else:
    prices.append(sum(buy[0]))
if len(prices) == 0:
  print(-1)
else:
  print(min(prices))

from operator import add

N,M,X = map(int,input().split())
C = []
A = []

for i in range(N):
    T = list(map(int,input().split()))
    C.append(T[0])
    A.append(T[1:])

ans = 100000000


for i in range(2**N):
    ex = [0]*M
    cost = 0
    Flag = True
    for j in range(N):
        if((i >> j) & 1):
            ex = list(map(add,ex,A[j]))
            cost += C[j]
    
    for k in range(M):
        if not ex[k] >= X:
            Flag = False
    
    if Flag:
        if cost <= ans:
            ans = cost


if ans == 100000000:
    print(-1)
else:
    print(ans)

#他の人の回答
n, m, x = map(int, input().split())
ca = [list(map(int,input().split())) for _ in range(n)]

add = []

for i in range(2**n):
    skill = [0]*(m+1)
    for j in range(n):
        if ((i>>j) & 1):
            skill = list(map(sum, zip(skill, ca[j])))
    if min(skill[1:])>=x:
        add.append(skill)

if add:
    add.sort()
    print(add[0][0])
else:
    print(-1)

n,m,x = map(int,input().split())
books = [list(map(int,input().split())) for _ in range(n)]
ans = 12 * (10**5) + 1
for i in range(2**n):
    kingaku = 0
    rikaido = [0] * m
    for j in range(n):
        if (i >> j) & 1:
            kingaku += books[j][0]
            for k in range(m):
                rikaido[k] += books[j][k+1]
    if all((a >= x for a in rikaido)):
        ans = min(ans,kingaku)
if ans != 12 * (10**5) + 1:
    print(ans)
else:
    print("-1")

N, M, X = list(map(int, input().split()))
C = []
A = []

for i in range(N):
    tmp = list(map(int, input().split()))
    C.append(tmp[0])
    A.append(tmp[1:])

ans = -1

for i in range(1, 1 << N):
    price = 0
    skill = [0] * M
    b = len(bin(i)) - 2
    for j in range(b):
        price += C[j] * (i >> j & 1)
        for k in range(M):
            skill[k] += A[j][k] * (i >> j & 1)

    if min(skill) >= X and (price < ans or ans < 0):
        ans = price

print(ans)


import numpy as np
N,M,X = map(int, input().split())
books = []
for i in range(N):
  tmp_book = list(map(int, input().split()))
  books.append(tmp_book)

ans = 10**10
for i in range(1,2**(N)):
  flag = 1
  ability = np.zeros(M)
  money = 0
  
  tmp = str(bin(i))
  tmp = '0'*(N-len(tmp[2:])) + tmp[2:]
  for j in range(N):
    if tmp[j] == '1':
      ability += books[j][1:]
      money += books[j][0]
  for j in range(M):
    if ability[j] < X:
      flag = 0
      break
  if flag == 1:		ans = min(ans, money)
if ans == 10**10:	print(-1)
else:				print(ans)

N,M,X = map(int,input().split())
a = [list(map(int,input().split())) for i in range(N)]
d = []
for i in range(2**N):
    b = [0] * (M+1)
    e = i
    for j in range(N):
        if e >= (2**(N-j-1)) :
            e -= (2**(N-j-1))
            for k in range(M+1):
                b[k] += a[j][k]
    c = 1
    for j in range(1,M+1):
        if b[j] < X:
            c = 0
            break
    if c == 1:
        d.append(b[0])
if len(d) > 0:
    ans = min(d)
else:
    ans = -1
print(ans)

n, m, x = map(int, input().split())
inp=[]

# 入力をすべて受け取る
for i in range(n):
  tmp = list(map(int, input().split()))
  inp.append(tmp)

# bit全探索を行うための箱づくり
sum = 0
min = 10**10
for i in range(2**n):
  tmp = [0]*m
  flg = 0
  
  # ある買う買わないのケースに対して、フラグが立ってたらスキルポイントを増やす
  for j in range(n):
    if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
      sum += inp[j][0]
      for k in range(1,m+1):
        #print(n,j, k, tmp, inp)
        tmp[k-1] += inp[j][k]
  for ii, k in enumerate(tmp):
    if k < x: # x未満ならflgをたててNGとする
      flg = 1
      break
  #print(tmp, flg)
  if sum < min and flg == 0: min = sum
  sum = 0
  
if min == 10**10: min = -1
print(min)

from itertools import product

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

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

ans = 10**12+1
for t in product([0,1], repeat=n): # (1, 0, 0)
    cost = 0
    understanding = [0] * m
    for i, b in enumerate(t):
        if b == 1:
            cost += CA[i][0]
            for j, a in enumerate(CA[i][1:]):
                understanding[j] += a  
    if sum(True for u in understanding if u >= x) == m:
        ans = min(ans, cost)

if ans == 10**12+1:
    print(-1)
else:
    print(ans)

import sys
import math
from collections import defaultdict, deque, Counter
from copy import deepcopy
from bisect import bisect, bisect_right, bisect_left
from heapq import heapify, heappop, heappush
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]
    
    
def main():
    N, M, X = MI()
    res = float('inf')
    D = Init(2**N, M, 0)
    C = defaultdict(int)
    L = [LI() for i in range(N)]
    for i in range(2**N):
        for j in range(N):
            if i >> j & 1 == 1 or C[i | 1 << j] > 0:
                continue
            for index, n in enumerate(L[j][1:]):
                D[i | 1 << j][index] = D[i][index] + n
            C[i | 1 << j] = C[i]+L[j][0]
    for i in range(1, 2**N):
        temp = D[i]
        ans = True
        for j in temp:
            if j < X:
                ans = False
                break
        if ans:
            res = min(res, C[i])
    if res == float('inf'):
        print(-1)
    else:
        print(res)
            
            
        




def __starting_point():
    main()
__starting_point()

n,m,x = map(int,input().split())
cost = []
cont = []
for i in range(n):
  c,*a = map(int,input().split())
  cost.append(c)
  cont.append(a)

ans = 10**9
for bit in range(1<<n):
  cnt = 0
  skills = [0]*m
  for i in range(n):
    if (bit>>i) & 1:
      cnt += cost[i]
      for j,pts in enumerate(cont[i]):
        skills[j] += pts
  if min(skills)>=x:
    ans = min(ans, cnt)
print(ans if ans<10**9 else -1)

nb,na,level = list(map(int , input().split()))
blevels = []
for i in range(nb):
    blevels.append(list(map(int , input().split())))
ans = float('inf')
#print(ans)
for i in range(1,2**nb):
    flag = 0
    levels_sum = [0]*na
    price_sum = 0
    for j in range(nb):
        if((1<<j) & i > 0):
            price_sum += blevels[j][0]
            for k in range(1,na+1):
                levels_sum[k-1] += blevels[j][k]
    #print(price_sum)
    #print(*levels_sum)
    for levels in levels_sum:
        if(levels < level):
         #   print("breaked")
            flag = 1
            break
    if(flag == 0 and ans > price_sum):
        ans = price_sum
        #print(ans)
if(ans != float('inf')):
    print(ans)
else:
    print("-1")


N, M, X = map(int, input().split())
C = []
A = []
for _ in range(N):
    l = list(map(int, input().split()))
    C.append(l[0])
    A.append(l[1:])
 
ans = -1
for i in range((1<<N)):
    u = [0] * M
    p = 0
    for j in range(N):
        if i & (1 << j):
            p += C[j]
            for k in range(M):
                u[k] += A[j][k]
    if min(u) >= X:
        if ans == -1 or ans > p:
            ans = p
print(ans)


url = "https://atcoder.jp//contests/abc160/tasks/abc160_c"

import itertools


def main():
    n, m , X = list(map(int, input().split()))
    books = []
    ans = -1
    for _ in range(n):
        books.append(list(map(int, input().split())))
    for i in range(n):
        for row in itertools.combinations(list(range(0, n)), i+1):
            cost = 0
            rikai = [0] * m
            for idx in row:
                cost += books[idx][0]
                for idx2 in range(1, len(books[idx])):
                    rikai[idx2 - 1] += books[idx][idx2]
                if len(list([x for x in rikai if x >= X])) == len(rikai):
                    ans = min(ans, cost) if ans != -1 else cost
    print(ans)








def __starting_point():
    main()

__starting_point()

from itertools import combinations
import numpy as np
n,m,x = map(int, input().split())
costs = []
understnding = []
ans = 10 ** 20

for _ in range(n):
    tmp = list(map(int, input().split()))
    costs.append(tmp[0])
    understnding.append(tmp[1:])
    
costs = np.array(costs)
understnding = np.array(understnding)

for i in range(1, 2**n):
    row = str(bin(i)).split("0b")[1]
    row = '0'*(n - len(row))+row
    one_index = [j for j in range(len(row)) if row[j] =="1"]
    cost_sum = np.sum(costs[one_index])
    under_sum = np.sum(understnding[one_index], axis=0)
    if np.all(under_sum >= x) and cost_sum < ans:
        ans = cost_sum
    
if ans == 10 ** 20:
    print(-1)
else:
    print(ans)

N,M,X=[int(s) for s in input().split()]
Book=[[int(s) for s in input().split()] for _ in range(N)]
INF=10**7

ans=set()
ans.add(INF)
#深さ優先探索
def DFS(n,cost,Xls):
  if n==N:
    if min(Xls)>=X:
      ans.add(cost)
  else:
    Xnext=[Xls[i]+Book[n][i+1] for i in range(M)]
    DFS(n+1,cost+Book[n][0],Xnext)
    DFS(n+1,cost,Xls)

DFS(0,0,[0 for _ in range(M)])
if min(ans)==INF:
  print(-1)
else:
  print(min(ans))

n,m,r = map(int,input().split())
books = [[int(i) for i in input().split()] for _ in range(n)]
t = []

for x in range(2**n):
    p = [0]*(m+1)
    for y in range(n):
        if (x>>y)&1 :
            p = [a+b for (a,b) in zip(books[y],p)]
    t.append(p)




ans = []


c = True

for z in t:
    c = True
    for s in range(1,m+1):
        if z[s] < r:
            c = False
    if c:
        ans.append(z[0])

if ans != []:
    print(min(ans))

else:
    print(-1)

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

for i in range(N):
    CA = list(map(int, input().split()))
    lis.append(CA)

ans = 1e9
for i in range(2 ** N):
    check = [0 for i in range(M + 1)]
    for j in range(N):
        if i >> j & 1:
            for k in range(M + 1):
                check[k] += lis[j][k]
        if min(check[1:]) >= X:
            ans = min(ans, check[0])
if ans == 1e9:
    print((-1))
else:
    print(ans)


#ABC167
N,M,X=map(int,input().split())
c = []  #参考書の値段
a = []  #各参考書に入る理解度
for i in range(N):
    c_temp, *a_temp = list(map(int, input().split()))  # こうすると、2つ目以降をリストで受け取れる
    c.append(c_temp)
    a.append(a_temp)
price_min = 10000000
for i in range(2**N):
    price_total = 0  #値段の合計
    learn_total = [0] * M #理解度の合計
    for j in range(N):
        if (i >> j) & 1:  # j桁目が0か1か見て、j冊目を買うか買わないか判定します
            price_total += c[j]  # 買うので、j冊目の値段を加算します
            learn = a[j]  # 「j冊目の参考書を読んで増える、各アルゴリズムの理解度」のリストです
            for k, la in enumerate(learn):  # 理解度を加算します enumerateを使うと、range(n)よりスマートです
                learn_total[k] += la
    if all(learn_total[k] >= X for k in range(M)):
        if price_min > price_total:
            price_min=price_total
            
if price_min==10000000:
    print (-1)
else:
    print (price_min)

import numpy as np
N,M,X = map(int,input().split())
C = []
A = []
for _ in range(N):
    l = list(map(int,input().split()))
    C.append(l[0])
    A.append(np.array(l[1:]))
ans = 10**100
for i in range(2**N):
    rikaido = np.zeros(M)
    c = 0
    for j in range(N):
        if (i >> j) & 1:
            c += C[j]
            rikaido += A[j]
    if all([x >= X for x in rikaido]):
        ans = min(ans, c)
print(ans if ans != 10**100 else -1)

n, m, x = list(map(int, input().split()))
ans = 10 ** 9
books = [tuple(map(int, input().split())) for _ in range(n)]
for i in range(2 ** (n + 1)):
    skill = [0 for _ in range(m)]
    money = 0

    for j in range(n):
        if i >> j & 1:
            book = books[j]
            money += book[0]
            for k, b in enumerate(book[1:]):
                skill[k] += b
    if all(s >= x for s in skill):
        ans = min(ans, money)
print((ans if ans != 10 ** 9 else - 1))


def main():
    n, m, x = list(map(int, input().split()))
    sofar = 10 ** 5 + 1
    cl = list(list(map(int, input().split())) for _ in range(n))
    # print(cl)
    ans = float('inf')
    for i in range(2 ** n):
        tmp = [0] * m
        cost = 0
        for j in range(n):
            # print(bin(j), i, bin(i >> j))
            if (i >> j) & 1:
                for k in range(m):
                    tmp[k] += cl[j][k + 1]
                cost += cl[j][0]
                # print(tmp)
        for t in tmp:
            if t < x:
                break
        else:
            ans = min(ans, cost)
    if ans == float('inf'):
        return -1
    else:
        return ans


def __starting_point():
    print((main()))

__starting_point()

N, M, X = map(int, input().split(' '))
A, C = [], []
for n in range(N):
  inp = list(map(int, input().split(' ')))
  C.append(inp[0])
  A.append(inp[1:])
  
def proceed_step(remained, current_cost, n):
  nonlocal N, X
  remained_next = []
  
  if not remained: return current_cost
  if n == N: return float('inf')
  
  for algorithm in remained:
    m, current_sum = algorithm[0], algorithm[1]
    current_sum += A[n][m]
    if current_sum < X:
      remained_next.append([m, current_sum])
      
  return min(proceed_step(remained, current_cost, n+1),
             proceed_step(remained_next, current_cost + C[n], n+1))

remained = [[m, 0] for m in range(M)]
total_cost = proceed_step(remained, current_cost=0, n=0)
if total_cost == float('inf'): print(-1)
else: print(total_cost)

import numpy as np
n,m,x = map(int, input().split())
li = []
for i in range(n):
    c_A = list(map(int, input().split()))
    li.append(c_A)

li = np.array(li)
cost = 10**7
for i in range(2**n):
    c_s = np.array([0]*(m+1))
    for j in range(n):
        if ((i>>j)&1):
            c_s += li[j]
    if np.all(c_s[1:]>=x):
        cost = min(cost,c_s[0])
if cost==10**7:
    print(-1)
else:
    print(cost)

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

def binary(i, cost, und):
    if i==n:
        for j in range(m):
            if und[j]<x:
                return float('inf')
        return cost

    left = binary(i+1, cost, und)
    right = binary(i+1, cost+ca[i][0], [und[k] + ca[i][k+1] for k in range(m)])

    mi = min(left, right)

    return mi

ans = binary(0, 0, [0]*m)
if ans == float('inf'):
    print((-1))
else:
    print(ans)


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

C=[]
A=[]
for i in range(N):
    t=list(map(int,input().split()))
    C.append(t[0])
    A.append(t[1:])

ans=-1
for i in range(1<<N):     #range(0,2^N)　左ビットシフト
    A_sum=[0]*M             #t=[0 0 0]など len(t)=M
    C_sum=0
    for j in range(N):
        if (i>>j)&1==0:   #jのフラグがないとき
            continue
        C_sum+=C[j]               #合計の値段
        for k in range(M):
            A_sum[k]+=A[j][k]     #合計の理解度  
    if all(x>=X for x in A_sum):  #tのすべての要素がXより大きいとき
        if ans==-1:
            ans=C_sum
        else:
            ans=min(ans,C_sum)
print(ans)

N,M,X=map(int,input().split())
L=[list(map(int,input().split())) for i in range(N)]
a=2**N
J=[]
for i in range(a):
    T=True
    K=[0]*(M+1)
    for j in range(N):
        if (i>>j)&1:
            for k in range(M+1):
                K[k]+=L[j][k]
    for j in range(1,M+1):
        if K[j]<X:
            T=False
    if T:
        J.append(K[0])
if len(J)==0:
    print(-1)
else:
    J.sort()
    print(J[0])

import itertools as it

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

combs = it.product([0, 1], repeat=N)
prices = []
for comb in combs:
	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]
	if min(bag[1:]) < X:
		continue
	else:
		prices.append(bag[0])

if len(prices) == 0:
	print(-1)
else:
	print(min(prices))

def i_input(): return int(input())


def i_map(): return list(map(int, input().split()))


def i_list(): return list(map(int, input().split()))


def i_row(N): return [int(input()) for _ in range(N)]


def i_row_list(N): return [list(map(int, input().split())) for _ in range(N)]
def bit_search(n, list_n):

    bit_ans=[]
    for _ in range(2**n):
        t = [0] * n
        bit_ans.append(t)
    for i in range(2 ** n):
        for j in range(n):
            if ((i >> j) & 1):
                bit_ans[i][j] = list_n[j]

    return bit_ans

cost=10**18
n,m,x= i_map()
caa=i_row_list(n)
ls=list(range(1,n+1))
bls=bit_search(n,ls)
for bb in bls:
    ch=[0]*(m+1)
    for i in range(n):
        if bb[i]!=0:
            ch= [ c + b for (c,b) in zip(ch, caa[bb[i]-1])]
    for i in range(m+1):
        if i==0:
            flg=1
            tmp=ch[i]
        else:
            if ch[i]<x:
                flg=0
    if flg==1:
        cost=min(cost,tmp)
if cost==10**18:
    cost=-1
print(cost)





import numpy as np
n,m,x = map(int, input().split())
costs = []
understnding = []
ans = 10 ** 20

for _ in range(n):
    tmp = list(map(int, input().split()))
    costs.append(tmp[0])
    understnding.append(tmp[1:])
    
costs = np.array(costs)
understnding = np.array(understnding)

for i in range(1, 2**n):
    row = str(bin(i)).split("0b")[1]
    row = '0'*(n - len(row))+row
    one_index = [j for j in range(len(row)) if row[j] =="1"]
    cost_sum = np.sum(costs[one_index])
    under_sum = np.sum(understnding[one_index], axis=0)
    if np.all(under_sum >= x) and cost_sum < ans:
        ans = cost_sum
    
if ans == 10 ** 20:
    print(-1)
else:
    print(ans)

from itertools import product
[N, M, X] = [int(i) for i in input().split()]
bk = [[int(i) for i in input().split()] for _ in range(N)]

ans = 12*10**5 + 1
for seq in product(range(2), repeat=N):
    S = [0]*(M+1)
    for i in range(N):
       for j in range(M+1):
           S[j] += seq[i]*bk[i][j]     
    if min(S[1:M+1]) >= X:
        ans = min(ans, S[0])

if ans == 12*10**5 + 1:
    print(-1)
else:
    print(ans)

from numpy import *
N, M, X = map(int, input().split())
B = [array(list(map(int, input().split())), uint32) for _ in range(N)]
c = inf
for i in range(2**N):
    a = zeros(M+1, uint32)
    j = 0
    while i:
        if i&1: a += B[j]
        i >>= 1
        j += 1
    C, *A = a
    if min(A) >= X: c = min([c, C])
print(c if c<inf else-1)

import numpy as np

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

cost = float("inf")
for i in range(2**N):
  tmp = np.array([0 for _ in range(M+1)])
  for j in range(N):
    if (i>>j) & 1:
      tmp += np.array(C[j])
  if min(tmp[1:]) >= X:
    cost = min(cost, tmp[0])

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

import numpy as np
N,M,X=map(int,input().split())
C=[[0 for i in range(M)] for j in range(N)]
for i in range(N):
    C[i] = list(map(int, input().split()))
D=np.array(C)
E=[0]*2**N

for i in range(2**N):
  c=format(i,'012b')
  for j in range(N):
    d=int(c[12-N+j])
    E[i]+=D[j]*int(d)

if min(E[-1][1:M+1])<X:
  print(-1);return
    
Max=E[-1][0]+1
Min=Max
for i in range(2**N):
  if min(E[i][1:M+1])>=X:
    if Min>E[i][0]:Min=E[i][0]
    continue
  else:E[i][0]=Max
print(Min)
return

import itertools as it

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

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]

    if min(bag[1:]) < X:
        continue
    else:
        prices.append(bag[0])

if len(prices) == 0:
    print(-1)
else:
    print(min(prices))

import itertools
N,M,X = map(int,input().split())
lsC = []
lsM = []
for i in range(N):
    ls = list(map(int,input().split()))
    C = ls.pop(0)
    lsC.append(C)
    lsM.append(ls)
lsP = itertools.product(range(2),repeat=N)
ans = 10**15
for i in lsP:
    Call = 0
    lsAll = [0]*M
    f = True
    for j in range(N):
        if i[j] == 1:
            Call += lsC[j]
            for k in range(M):
                lsAll[k] += lsM[j][k]
    for l in range(M):
        if lsAll[l] < X:
            f = False
            break
    if f:
        ans = min(ans,Call)
if ans == 10**15:
    print(-1)
else:
    print(ans)

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

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

# print(array)
# print(n)
ans = 10 ** 8
for i in range(2**n):

    skill = [0] * m
    price = 0
    count = 0
    for k in range(n):
        if (i >> k) & 1:

            price += array[k][0]
            for j in range(m):
                skill[j] += array[k][j+1]
    for l in range(m):
        if skill[l] < x:
            break
        else:
            count += 1
    if count == m:
        ans = min(ans, price)

if ans == 10**8:
    print((-1))
else:
    print(ans)





def __starting_point():

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

    A = []
    for i in range(n):
        cmd = list(map(int,input().split()))
        A.append(cmd)
    #bit全探索 買う・買わないを判断する
    INF = 10**19
    ans = INF
    for x in range(2**n):
        ALG = [0]*m
        gokei = 0
        for y in range(n):
            if (x>>y) & 1:
                #取得する配列が決まったら、アルゴリズム理解度を＋していく
                for j in range(m):
                    ALG[j] += A[y][j+1]
                gokei += A[y][0]
        #Alg配列の中身がすべて理解度xを超えているかのチェック
        algflg=True
        for k in ALG:
            if k < a:
                algflg=False
                break
        if algflg:
            ans = min(ans,gokei)
    if ans == INF:
        print("-1")
    else:
        print(ans)

__starting_point()

import sys
from collections import deque, defaultdict, Counter
from itertools import accumulate, product, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right
from heapq import heappop, heappush
from math import ceil, floor, sqrt, gcd, inf
from copy import deepcopy
import numpy as np
import scipy as sp

INF = inf
MOD = 1000000007

n, m, x = [int(i) for i in input().split()]
A = [[int(i) for i in input().split()]for j in range(n)]    # nは行数

tmp = 0
res = inf

for i in range(2 ** n):
    s = f"{i:0{n}b}"
    tmp = [0 for i in range(m + 1)]
    for j in range(n):
        if s[j] == "1":
            for k in range(m + 1):
                tmp[k] += A[j][k]
    flg = True
    for k in range(1, m + 1):
        if tmp[k] < x:
            flg = False
    if flg:
        res = min(res, tmp[0])
if res == inf:
    res = -1

print(res)


import numpy as np
N,M,X = map(int,input().split())
C = []
A = [[0]*M for i in range(N)]
for i in range(N):
  temp = list(map(int,input().split()))
  C.append(temp[0])
  A[i]=temp[1:]
#print(A)
global_sum = 100000000
algorithm =  np.array([0]*M)

def check(alg,X):
  flag = 1
  for i in range(len(alg)):
    if alg[i] < X:
      flag=0
  if flag ==1:
    return True
  else:
    return False
flag_2 = 0 
def calc(local_sum,alg,number,X):
  nonlocal global_sum 
  nonlocal flag_2
  #print(local_sum,alg,number)
  if check(alg,X):
    flag_2 = 1
    if global_sum > local_sum:
      global_sum = local_sum
    return local_sum
  elif number<N:
    ## 買わない
    alg = alg
    calc(local_sum,alg,number+1,X)
    ## 買う
    alg = alg + A[number]
    calc(local_sum+C[number],alg,number+1,X)
  else:
    return
calc(0,algorithm,0,X)
if flag_2 == 0 :
  global_sum=-1
print(global_sum)

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

C = []
A = []

for _ in range(N):
    q = list(map(int, input().split()))

    C.append(q[0])
    A.append(q[1:])

#bit全探索

ans = 1300000

for bit in range(1 << N):
    acquire = [0] * M
    cost = 0
    for i in range(N):
        if (bit >> i) % 2 == 1:
            cost += C[i]
            acquire = [a + b for a, b in zip(acquire, A[i])]

    if min(acquire) >= X:
        ans = min(ans, cost)

if ans == 1300000:
    ans = -1

print(ans)

from itertools import combinations

N, M, X = map(int, input().split())
C, A = [], []
for i in range(N):
    c, *a = map(int, input().split())
    C.append(c)
    A.append(a)

ans = float('INF')
for i in range(1,N+1):
    for li in combinations(list(range(N)), i):
        cost = 0
        skill = [0] * M
        for j in li:
            cost += C[j]
            for k in range(M):
                skill[k] += A[j][k]
        if all([s >= X for s in skill]):
            ans = min(ans, cost)
if ans == float('INF'):
    print(-1)
else:
    print(ans)

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

# 入力をすべて受け取る
for i in range(n):
  tmp = list(map(int, input().split()))
  inp.append(tmp)

# bit全探索を行うための箱づくり
sum = 0
min = 10**10
for i in range(2**n):
  tmp = [0]*m
  flg = 0
  
  # ある買う買わないのケースに対して、フラグが立ってたらスキルポイントを増やす
  for j in range(n):
    if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
      sum += inp[j][0]
      for k in range(1,m+1):
        #print(n,j, k, tmp, inp)
        tmp[k-1] += inp[j][k]
  for ii, k in enumerate(tmp):
    if k < x: # x未満ならflgをたててNGとする
      flg = 1
      break
  #print(tmp, flg)
  if sum < min and flg == 0: min = sum
  sum = 0
  
if min == 10**10: min = -1
print(min)


import itertools as it

N,M,X=list(map(int,input().split()))
book = [[int(_) for _ in input().split()] for i in range(N)]

combs = it.product([0, 1], repeat=N)
prices = []
for comb in combs:
	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]
	if min(bag[1:]) < X:
		continue
	else:
		prices.append(bag[0])

if len(prices) == 0:
	print((-1))
else:
	print((min(prices)))


N, M, X = map(int, input().split())
item = []
ans = []
for i in range(N):
  item.append(list(map(int, input().split())))
for i in range(2**N):
  bag = []
  money = 0
  for j in range(N):
    if ((i>>j) & 1):
      bag.append(item[j])
  if bag == []:
    continue
  total = [0] * M
  for k in bag:
    money += k[0]
    for l in range(1, M+1):
      total[l-1] += k[l]
  if min(total) >= X:
    ans.append(money)
if ans == []:
  print(-1)
else:
  print(min(ans))

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

c = []
a = []

for i in range(n):
    c.append(ca[i][0])
    a.append(ca[i][1:])

INF = 10**9
ans = INF

for i in range(1 << n):
    sum_cost = 0
    skill = [0]*m
    for j in range(n):
        if (i >> j)&1:
            sum_cost += c[j]
            for k in range(m):
                skill[k] += a[j][k]
    check_cnt = 0
    for l in range(m):
        if skill[l] >= x:
            check_cnt += 1
    if check_cnt == m:
        ans = min(ans,sum_cost)

if ans == INF:
    print((-1))
else:
    print(ans)


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

li=[]
ans=100000000000000000000000000000000

for j in range(N):
    a=list(map(int,input().split()))
    li.append(a)

for k in range(2**N):
    temp=0
    skill=[0]*M
    k=str(bin(k))
    k=k[2:]
    while len(k)!=N:
        k="0"+k
    for l in range(N):
        if k[l]=="1":
            temp+=li[l][0]
            for m in range(1,M+1):
                skill[m-1]+=li[l][m]
    if min(skill)>=X:
        if ans>temp:
            ans=temp
if ans==100000000000000000000000000000000:
    print((-1))
else:
    print(ans)


N,M,X = map(int,input().split())
array = [ list(map(int,input().split())) for _ in range(N) ]
ans = 10**18
for i in range ( 2**N ):
  price = 0
  skill = [0]*M
  count = 0
  for k in range(N):
    if ( i >> k ) & 1:
      price += array[k][0]
      for j in range (M):
        skill[j] += array[k][j+1]
  for t in range(M):
    if skill[t] < X:
      break
    else:
      count += 1
    if count == M:
      ans = min(price,ans)
      
print( -1 if ans == 10**18 else ans)

import sys
def input(): return sys.stdin.readline().rstrip()
INF = 10000000000000
N,M,X = map(int,input().split())

C = []
A = []
for i in range(N):
    vec = list(map(int,input().split()))
    C.append(vec[0])
    A.append(vec[1:])

ans = INF

for bit in range(1 << N):
    sum = 0
    skill = [0] * M
    for n in range(N):
        if bit & (1 << n):
            for i, s in enumerate(A[n],0):
                skill[i] += s
            sum += C[n]

    flag = True
    for i in range(M):
        if skill[i] < X:
            flag = False
            break
    if flag:
        ans = min(ans,sum)

if ans == INF:
    print(-1)
else:
    print(ans)

import numpy as np

N,M,X = map(int, input().split())
books = []
for i in range(N):
  tmp_book = list(map(int, input().split()))
  books.append(tmp_book)

ans = 10**10
for i in range(1,2**(N)):
  flag = 1
  tmp = str(bin(i))
  if len(tmp[2:]) < N:
    tmp = '0'*(N-len(tmp[2:])) + tmp[2:]
  else:
    tmp = tmp[2:]
  ability = np.zeros(M)
  money = 0
  for j in range(N):
    if tmp[j] == '1':
      ability += books[j][1:]
      money += books[j][0]
  #print(ability)
  for j in range(M):
    if ability[j] < X:
      flag = 0
      break
  if flag == 1:
    ans = min(ans, money)
if ans == 10**10:
  print(-1)
else:
  print(ans)

# -*- coding: utf-8 -*-

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

ans = -1
for i in range(1<<N):
    bit = [0] * N
    for j in range(N):
        div = 1 << j
        bit[j] = (i // div) % 2

    res = [0] * M
    cost = 0
    for n in range(N):
        if bit[n]==0:
            continue
        cost += CA[n][0]
        for m in range(1,M+1):
            res[m-1] += CA[n][m]

    flag = True
    for m in range(M):
        if res[m] < X:
            flag = False
            break
    
    if flag:
        if ans == -1:
            ans = cost
        else:
            ans = min(ans, cost)

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)))


from copy import deepcopy

N, M, X = [int(i) for i in input().split()]

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


ok = False
mi = [float('inf'), *[0]*(M)]

fs = '{:0' + str(N) + 'b}'

for i in range(2**N):
  s = fs.format(i)
  t = [0]*(M+1)
  for i, f in enumerate(s):
    if f == '1':
      t = [a+b for a, b in zip(CAS[i], t)]

  if all(a >= X for a in t[1:]) and mi[0] > t[0]:
    mi = t
    ok = True


if ok:
  print((mi[0]))
else:
  print((-1))


n,m,x = map(int,input().split())
c = [list(map(int,input().split())) for _ in range(n)]
ans = []
#n冊の本において買うか買わないかの2通りなので2**n
for i in range(2**n):
    #リストの中身は値段1と理解度m個
    a = [0]*m
    price = 0
    for j in range(n):
        #n冊あるうちj冊目を買うか買わないかを判定
        if ((i >> j) & 1):
            for k in range(m):
                a[k] += c[j][k+1]
            #j冊めを買うので、合計金額を増やす
            price += c[j][0]
    if all(j >= x for j in a):
        ans.append(price)

if len(ans) == 0:
    print("-1")
else:
    print(min(ans))

n, m, x = list(map(int, input().split()))
ll = [list(map(int, input().split())) for _ in range(n)]
ans = 10**9

for i in range(2**n):
    a = [0]*m
    cnt = 0
    for j in range(n):
        if i>>j & 1:
            for k in range(1, m+1):
                a[k-1] += ll[j][k]
            cnt += ll[j][0]
    if all(s >= x for s in a):
        ans = min(ans, cnt)
print((ans if ans < 10**9 else -1))


import numpy as np
import itertools

def check():
    N,M,X = map(int, input().split())
    A = np.array([[int(i) for i in input().split()] for _ in range(N)])
    total = np.sum(A,axis=0)
    flag = True if all((a>=X  for a in total[1:])) else False
    ans = total[0]

    if flag:
        for i in range(1,N+1):
            for v in itertools.combinations([i for i in range(N)], i):
                B = np.array([A[j] for j in v])
                total2 = np.sum(B, axis=0)
                sabun = total-total2
                if all(a>=X for a in sabun[1:]):
                    ans = min(ans, sabun[0])
    print(ans if flag else -1)
    
check()

import itertools
import numpy as np
import copy

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

ans = 10 ** 7
for i in itertools.product([0, 1], repeat=N):
    tCA = copy.copy(CA)
    for j in range(N):
        if i[j] == 0:
            tCA[j] = np.zeros(CA.shape[1])
    s = np.sum(tCA, axis=0)
    l = sum(k >= X for k in s[1:])
    if s[0] < ans and l == M:
        ans = s[0]

if ans == 10 ** 7:
    print((-1))
else:
    print(ans)


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

c = []
a = []
for i in range(n):
    c.append(ca[i][0])
    a.append(ca[i][1:])

INF = 10**9
ans = INF
for i in range(1<<n):
    skill = [0]*m
    sum_cost = 0
    for j in range(n):
        if (i >> j)&1:
            for k in range(m):
                skill[k] += a[j][k]
            sum_cost += c[j]
    if min(skill) >= x:
        ans = min(ans,sum_cost)

if ans == INF:
    print((-1))
else:
    print(ans)


import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
#import numpy as np
from itertools import product
def main():
    n, m, x = list(map(int, input().split()))
    books = []
    for _ in range(n):
        books.append(tuple(map(int, input().split())))
    p = tuple(product((0, 1), repeat=n))
    r = float('inf')
    for pe in p:
        effects = [0] * (m + 1)
        for i1 in range(n):
            if pe[i1]:
                for i2 in range(m+1):
                    effects[i2] += books[i1][i2]
        if all([e >= x for e in effects[1:]]):
            r = min(r, effects[0])
    if r == float('inf'):
        print((-1))
    else:
        print(r)

def __starting_point():
    main()

__starting_point()

#
# abc167 c
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """3 3 10
60 2 2 4
70 8 7 9
50 2 3 9"""
        output = """120"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """3 3 10
100 3 1 4
100 1 5 9
100 2 6 5"""
        output = """-1"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """8 5 22
100 3 7 5 3 1
164 4 5 2 7 8
334 7 2 7 2 9
234 4 7 2 8 2
541 5 4 3 3 6
235 4 8 6 9 7
394 3 6 1 6 2
872 8 4 3 7 2"""
        output = """1067"""
        self.assertIO(input, output)


def resolve():
    N, M, X = list(map(int, input().split()))
    CA = [list(map(int, input().split())) for _ in range(N)]

    ans = float("inf")
    for bit in range(1 << N):
        S = [0]*(M+1)
        for i, ca in enumerate(CA):
            if (1 << i) & bit == 1 << i:
                S = list(map(sum, list(zip(S, ca))))
        for s in S[1:]:
            if s < X:
                break
        else:
            ans = min(ans, S[0])

    if ans == float("inf"):
        ans = -1

    print(ans)


def __starting_point():
    # unittest.main()
    resolve()

__starting_point()

from copy import deepcopy

N, M, X = [int(i) for i in input().split()]

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


ok = False
mi = [float('inf'), *[0]*(M)]

for i in range(2**N):
  t = [0]*(M+1)
  for j in range(N):
    if (i >> j) & 1:
      t = [a+b for a, b in zip(CAS[j], t)]

  if all(a >= X for a in t[1:]) and mi[0] > t[0]:
    mi = t
    ok = True


if ok:
  print((mi[0]))
else:
  print((-1))


import sys
N, M, X = map(int, input().split())
C = [0 for _ in range(N)]
A = [[0 for _ in range(M)] for _ in range(N)]
for i in range(N):
    S = list(map(int, input().split()))
    C[i] = S[0]
    for j in range(1,M+1):
        A[i][j-1] = S[j]
 
ans = 10**9
for i in range(2**N):
    hantei = 0
    tmp = 0
    score = [0]*M
    for n in range(N):
        if (i >> n) & 1 == 1:
            tmp += C[n]
            for j in range(M):
                score[j] += A[n][j]

    for j in range(M):
        if score[j]>=X: hantei += 1 
    if hantei == M:
        ans = min(ans, tmp) 
    if i == 2**N -1 and hantei != M:
        print(-1)
        return      
    
print(ans)


def main():
    n, m, x = map(int, input().split(" "))
    ca =[]
    a = []
    c = []
    INF = 1e7
    ans = INF
    for i in range(n):
        ca.append(list(map(int, input().split(" "))))
    for i in range(n):
        c.append(ca[i][0])
        a.append(ca[i][1:])
    for i in range(1<<n):
        a_sum = [0]*m
        c_sum = 0
        for j in range(n):
            if i >> j & 1 == 1:
                for k in range(m):
                    a_sum[k] += a[j][k]
                c_sum += c[j]
        if min(a_sum) >= x and c_sum < ans:
            ans = c_sum
    if ans == INF:
        print(-1)
    else:
        print(ans)
        

def __starting_point():
    main()
__starting_point()

# author:  Taichicchi
# created: 14.09.2020 22:23:14

import sys
from itertools import combinations

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

C = []
A = []

for i in range(N):
    c, *a = list(map(int, input().split()))
    C.append(c)
    A.append(a)
comb = [0, 1, 2]

save = []

for choice in range(1, N + 1):
    for comb in combinations(list(range(N)), choice):
        ls = [0 for _ in range(M)]
        for i in comb:
            for m in range(M):
                ls[m] += A[i][m]
            if all(list([x >= X for x in ls])):
                save.append(sum([C[_] for _ in comb]))
if save:
    print((min(save)))
else:
    print((-1))


n,m,x=[int(i) for i in input().split()]
c=[]
arr=[[] for i in range(n)]
for i in range(n):
    l=[int(i) for i in input().split()]
    c.append(l[0])
    arr[i]=l[1:]

inf=10**18
ans=inf

limit=2**n
for bit in range(1,limit):
    sum=[0 for i in range(m)]
    cost=0
    for i in range(n):
        if (1<<i & bit):
            cost+=c[i]
            for j in range(m):
                sum[j]+=arr[i][j]
    flag=1
    for i in range(m):
        if sum[i]<x:
            flag=0
            break
    if flag==0:
        continue
    ans=min(ans,cost)
if ans!=inf:
    print(ans)
else:
    print((-1))


n,m,x=list(map(int,input().split()))
l=[list(map(int,input().split(" "))) for i in range(n)]
ans=[]
for i in range(1<<n):
    cond = [0]*n
    for j in range(n):
        if 1&(i>>j):
            cond[j] = 1
    count=[0]*(m+1)
    for k in range(n):
        if cond[k]==1:
            for s in range(m+1):
                count[s]+=l[k][s]
    flag=0
    for a in range(1,m+1):
        if count[a]<x:
            flag=1
            break
    if flag==0:
        ans.append(count[0])
if ans==[]:
    print((-1))
else:
    print((min(ans)))
            


N, M, X = list(map(int, input().split()))
a = []
for i in range(N):
    a.append(list(map(int, input().split())))

d = []

for i in range(1 << N):
    s = [0] * M
    c = 0
    for j in range(N):
        if (i >> j) & 1:
            # print(j, "entry")
            for k in range(M):
                s[k] += a[j][k+1]
            c += a[j][0]

    # print(s, c, d)

    b = True
    for ii in s:
        if ii < X:
            b = False
    if b:
        d.append(c)

if len(d) == 0:
    print("-1")
else:
    print((min(d)))




[N, M, X] = list(map(int, list(input().split(' '))))
A = []
C = []
for i in range(N):
    c, *a = list(map(int, input().split(' ')))
    C.append(c)
    A.append(a)
#print(C)
#print(A)

INF = 10**10
min_cost = INF

for b in range(2**N): 
    # これがバイナリーベースの全探索となる。今回のキモ part 1
    # 一つのループが本の購入セットに対応している
    # 各ビットがそれぞれの本を購入するかどうか表している
    # 因みに b は bit を表しているつもり
    cost = 0 # この購入セットで使う金額
    algo_level = [0] * M # 各アルゴリズムトピックの理解度
    for i in range(N): 
        # これが各本のコストと理解度取得のためのループ
        # i 番目の本に対してループを回していく
        if(b >> i & 1): # この行が今回のキモ part 2。
            # i 番目の本の購入有無を判定するために、ビットシフトした値に対して '1 = 0b1' (つまり単なる (2進数の) 1) との論理積を求めている
            # この if 文が True であるということは、i 番目の本を買ったということ
            cost += C[i]
            for a in range(M): # (各本にある) 各アルゴリズムに対するループ
                algo_level[a] += A[i][a]
    if(min(algo_level) >= X): # 全てのアルゴリズムトピックが X 以上の理解度である場合…
        min_cost = min(cost, min_cost)

if(min_cost < INF):
    print(min_cost)
else:
    print('-1')






from itertools import combinations

def solve():
  N, M, X = map(int, input().split())
  C = []
  A = []
  for _ in range(N):
    c, *A_ = list(map(int, input().split()))
    C.append(c)
    A.append(A_)
    # print(C, list(A_))

  ret = 10**9
  for m in range(1, N+1):
    for comb in combinations(range(N), m):
      vec = [0]*M
      cost = 0
      for i in comb:
        for j,A_e in enumerate(A[i]):
          vec[j] += A_e
        cost += C[i]

      # print(comb, vec)
      if min(vec) >= X:
        ret = min(ret, cost)

  print(ret if ret < 10**9 else -1)
  
solve()