AtCoder Beginner Contest 167 - Skill Up

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: EASY

Starter code:

Solutions:
f = lambda : map(int, input().split())
(n, m, x) = f()
(lc, ll) = ([], [])
for _ in range(n):
	(c, *l) = f()
	lc += [c]
	ll += [l]
a = 10 ** 9
for i in range(2 ** n):
	(lm, t) = ([0] * m, 0)
	for j in range(n):
		if i >> j & 1:
			for k in range(m):
				lm[k] += ll[j][k]
			t += lc[j]
	if all((s >= x for s in lm)):
		a = min(a, t)
print([-1, a][a < 10 ** 9])


(n, m, x) = [int(i) for i in input().split()]
l = list()
INF = float('inf')
ans = INF
for i in range(n):
	(c, *a) = [int(i) for i in input().split()]
	l.append((c, a))
for b in range(1, 1 << n):
	p = 0
	lm = [0] * m
	for j in range(n):
		if b >> j & 1:
			p += l[j][0]
			for (k, v) in enumerate(l[j][1]):
				lm[k] += v
	if min(lm) >= x:
		ans = min(ans, p)
if ans == INF:
	print(-1)
else:
	print(ans)


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]
		elif ch[i] < x:
			flg = 0
	if flg == 1:
		cost = min(cost, tmp)
if cost == 10 ** 18:
	cost = -1
print(cost)


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)


((n, m, x), *t) = [[*map(int, t.split())] for t in open(0)]
m = M = 9 ** 9
for i in range(1, 2 ** n):
	(c, *a) = map(sum, zip(*[t[j] for j in range(n) if i >> j & 1]))
	m = min(m, M * (min(a) < x) or -~c)
print(m % M - 1)


(n, m, x) = map(int, input().split())
lis = [list(map(int, input().split())) for i in range(n)]
c = float('inf')
p = 0
for i in range(2 ** (n + 1)):
	al = [0] * m
	cost = 0
	for j in range(n):
		if i >> j & 1:
			for k in range(1, m + 1):
				al[k - 1] += lis[j][k]
			cost += lis[j][0]
	if min(al) >= x:
		c = min(c, cost)
		p = 1
print(c) if p == 1 else print(-1)


import sys
input = lambda : sys.stdin.readline().rstrip()
(n, m, x) = map(int, input().split())
A = [[int(i) for i in input().split()] for _ in range(n)]
ans = float('inf')
for i in range(2 ** n):
	B = [0] * (m + 1)
	for j in range(n):
		if i & 1 << j:
			for k in range(m + 1):
				B[k] += A[j][k]
	if min(B[1:]) >= x:
		ans = min(ans, B[0])
print(-1 if ans == float('inf') else ans)


(N, M, X) = map(int, input().split())
s = [list(map(int, input().split())) for i in range(N)]
t = [-1]
for i in range(1 << N):
	u = [0] * (M + 1)
	for j in range(N):
		if i >> j & 1 == 1:
			u = [u[k] + s[j][k] for k in range(M + 1)]
	for k in range(M):
		if u[k + 1] < X:
			break
	else:
		if t == [-1]:
			t.clear()
		t.append(u[0])
t.sort()
print(t[0])


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


from itertools import combinations
(n, m, x) = map(int, input().split())
ca = [list(map(int, input().split())) for _ in range(n)]
ans = 10 ** 9
for i in range(1, n + 1):
	for j in combinations(ca, i):
		t = [0] * (m + 1)
		for k in j:
			for l in range(m + 1):
				t[l] += k[l]
		if all((t[a] >= x for a in range(1, m + 1))):
			ans = min(ans, t[0])
if ans == 10 ** 9:
	print(-1)
else:
	print(ans)


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_)
	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]
			if min(vec) >= X:
				ret = min(ret, cost)
	print(ret if ret < 10 ** 9 else -1)
solve()


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


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


def resolve():
	((N, M, X), *T) = [[*map(int, i.split())] for i in open(0)]
	ans = []
	for i in range(1, 2 ** N):
		tmp = []
		for j in range(N):
			if i >> j & 1 == 1:
				tmp.append(T[j])
		(c, *a) = map(sum, zip(*tmp))
		if min(a) >= X:
			ans.append(c)
	if ans:
		print(min(ans))
	else:
		print(-1)
resolve()


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)


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 itertools
(N, M, X) = map(int, input().split())
l = [list(map(int, input().split())) for i in range(N)]
it = list(itertools.product([0, 1], repeat=N))
ANS = 10 ** 9
for i in it:
	arr = [0] * (M + 1)
	for j in range(N):
		arr = list(map(lambda x, y: x + y * i[j], arr, l[j]))
	if all([k >= X for k in arr[1:]]):
		ANS = min(ANS, arr[0])
if ANS == 10 ** 9:
	ANS = -1
print(ANS)


(N, M, X) = map(int, input().split())
CA = [list(map(int, input().split())) for i in range(N)]
cost = []
for i in range(2 ** N):
	one = str(bin(i)).count('1')
	ca_list = [0] * M
	c = 0
	for j in range(N):
		if i >> j & 1:
			c += CA[j][0]
			for k in range(M):
				ca_list[k] += CA[j][k + 1]
	if min(ca_list) >= X:
		cost.append(c)
if cost:
	print(min(cost))
else:
	print(-1)


(N, M, X) = map(int, input().split())
A = [input().split() for _ in range(N)]
ans = []
for i in range(2 ** N):
	score = [0] * M
	price = 0
	for j in range(N):
		if i >> j & 1:
			price += int(A[j][0])
			for k in range(M):
				score[k] += int(A[j][k + 1])
	if sorted(score)[0] >= X:
		ans.append(price)
print(-1 if len(ans) == 0 else min(ans))


(N, M, X) = map(int, input().split())
A = [list(map(int, input().split())) for i in range(N)]
ans = 10 ** 10
for i in range(2 ** N):
	cost = 0
	rikai = [0 for i in range(M)]
	for j in range(N):
		if i >> j & 1:
			cost += A[j][0]
			for k in range(M):
				rikai[k] += A[j][k + 1]
	if min(rikai) >= X:
		ans = min(ans, cost)
print(-1 if ans == 10 ** 10 else 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)


(N, M, X) = map(int, input().split())
CA = [list(map(int, input().split())) for _ in range(N)]
max_ = 10 ** 16
ans = max_
for bit in range(2 ** N):
	check = [0] * M
	ans_ = 0
	for i in range(N):
		if bit >> i & 1:
			ans_ += CA[i][0]
			for j in range(M):
				check[j] += CA[i][j + 1]
	if all([k >= X for k in check]):
		ans = min(ans, ans_)
print(ans if ans != max_ else -1)


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:]
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
	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) = 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)


(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) = map(int, input().split())
c = [list(map(int, input().split())) for _ in range(n)]
ans = []
for i in range(2 ** n):
	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))):
		ans.append(price)
if len(ans) == 0:
	print(-1)
else:
	print(min(ans))


(N, M, X) = map(int, input().split())
A = [list(map(int, input().split())) for n in range(N)]
a = 10 ** 9
for i in range(2 ** N):
	S = (M + 1) * [0]
	for j in range(N):
		if i >> j & 1:
			S = [S[k] + A[j][k] for k in range(M + 1)]
	if all([X <= s for s in S[1:]]):
		a = min(a, S[0])
if a == 10 ** 9:
	print(-1)
else:
	print(a)


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


(n, m, x) = list(map(int, input().split()))
array = [list(map(int, input().split())) for _ in range(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)


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)
	cost_per_cost = data[:, 0]
	effect_per_book = data[:, 1:]
	costs = np.zeros(2 ** n, np.int64)
	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()


(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) = map(int, input().split())
c = [list(map(int, input().split())) for _ in range(n)]
result = -1
for i in range(2 ** n):
	t = [0] * m
	money = 0
	for j in range(n):
		if i >> j & 1 == 0:
			continue
		money += c[j][0]
		for k in range(1, m + 1):
			t[k - 1] += c[j][k]
	if all((xx >= x for xx in t)):
		if result == -1:
			result = money
		else:
			result = min(result, money)
print(result)


(n, m, x) = map(int, input().split())
B = []
for i in range(n):
	B.append(list(map(int, input().split())))
ans = 10 ** 9
for i in range(2 ** n):
	A = [0] * m
	cnt = 0
	for j in range(n):
		if i >> j & 1:
			cnt += B[j][0]
			for k in range(m):
				A[k] += B[j][k + 1]
	if min(A) >= x:
		ans = min(cnt, ans)
if ans == 10 ** 9:
	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)
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:
			sum += inp[j][0]
			for k in range(1, m + 1):
				tmp[k - 1] += inp[j][k]
	for (ii, k) in enumerate(tmp):
		if k < x:
			flg = 1
			break
	if sum < min and flg == 0:
		min = sum
	sum = 0
if min == 10 ** 10:
	min = -1
print(min)


(n, m, x1) = map(int, input().split())
c = [list(map(int, input().split())) for i in range(n)]
ans = pow(10, 9)
for i in range(2 ** n):
	cnt = 0
	x = [0] * m
	for j in range(n):
		if i >> j & 1:
			cnt += c[j][0]
			for k in range(1, m + 1):
				x[k - 1] += c[j][k]
	if min(x) >= x1:
		ans = min(cnt, ans)
if ans == pow(10, 9):
	print(-1)
else:
	print(ans)


(n, m, x) = map(int, input().split())
a = [list(map(int, input().split())) for i in range(n)]
ans = 10 ** 10
for bit in range(1 << n):
	b = [0] * m
	c = 0
	for i in range(n):
		if bit & 1 << i:
			for j in range(m):
				b[j] += a[i][j + 1]
			c += a[i][0]
	if min(b) >= x:
		ans = min(ans, c)
if ans == 10 ** 10:
	print(-1)
else:
	print(ans)


(N, M, X) = map(int, input().split())
listA = [list(map(int, input().split())) for i in range(N)]
ans = -1
for i in range(2 ** N):
	price = 0
	point = [0] * M
	for j in range(N):
		if i >> j & 1 == 1:
			price += listA[j][0]
			for k in range(M):
				point[k] += listA[j][k + 1]
	if min(point) >= X:
		ans = min(ans, price) if ans != -1 else price
print(ans)


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


(n, m, x) = map(int, input().split())
text = []
buy = 10 ** 10
for i in range(n):
	text.append(list(map(int, input().split())))
for i in range(2 ** n):
	bag = [0] * (m + 1)
	for j in range(n):
		if i >> j & 1:
			for k in range(m + 1):
				bag[k] += text[j][k]
	if min(bag[1:]) >= x and bag[0] < buy:
		buy = bag[0]
if buy == 10 ** 10:
	buy = -1
print(buy)


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)


(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 = []
for i in range(2 ** n):
	A = [0] * m
	C = 0
	lst = list(map(int, format(i, 'b').zfill(n)))
	for j in range(n):
		if lst[j] == 1:
			C += c[j]
			for k in range(m):
				A[k] += a[j][k]
	if all((elem >= x for elem in A)):
		ans.append(C)
if len(ans):
	print(min(ans))
else:
	print(-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)))
	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'):
		return -1
	else:
		return ans

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


((N, M, X), *T) = [[*map(int, line.split())] for line in open(0)]
ans = 12345678
for bit in range(1, 2 ** N):
	t = [T[i] for i in range(N) if bit & 1 << i]
	(c, *a) = map(sum, zip(*t))
	if all((e >= X for e in a)):
		ans = min(ans, c)
print(-1 if ans == 12345678 else ans)


(n, m, x) = map(int, input().split())
ca = [list(map(int, input().split())) for i in range(n)]
ans = 10 ** 15
for i in range(2 ** n):
	rikai = [0] * m
	money = 0
	for j in range(n):
		if i >> j & 1:
			for k in range(m):
				rikai[k] += ca[j][k + 1]
			money += ca[j][0]
	if min(rikai) >= x:
		ans = min(ans, money)
if ans == 10 ** 15:
	print(-1)
else:
	print(ans)


(N, M, X) = map(int, input().split())
C = [list(map(int, input().split())) for i in range(N)]
INF = float('inf')
ans = INF
for i in range(1, 2 ** N):
	skills = [0] * M
	total_cost = 0
	for j in range(N):
		if i >> j & 1:
			total_cost += C[j][0]
			for k in range(M):
				skills[k] += C[j][k + 1]
	if min(skills) >= X:
		ans = min(ans, total_cost)
print(ans if ans != INF 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())
l = [list(map(int, input().split())) for _ in range(n)]
ans = float('inf')
for i in range(2 ** n):
	ll = [0 for _ in range(m + 1)]
	now = 0
	for j in range(n):
		if i >> j & 1:
			now += l[j][0]
			for k in range(m):
				ll[k + 1] += l[j][1 + k]
	if all((ll[s] >= x for s in range(1, m + 1))):
		ans = min(ans, now)
print(ans if ans != float('inf') else -1)


from itertools import product as pr
(n, m, x) = [int(i) for i in input().split()]
l = [[int(i) for i in input().split()] for j in range(n)]
p = list(pr([0, 1], repeat=n))
suml = [[sum([l[j][k] * i[j] for j in range(n)]) for k in range(m + 1)] for i in p]
ans = [i[0] for i in suml if all([i[j] >= x for j in range(1, m + 1)])]
if len(ans) == 0:
	print(-1)
else:
	print(min(ans))


(N, M, X) = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(N)]
ans = 10 ** 7
for i in range(1 << N):
	s = [0] * M
	kari = 0
	for j in range(N):
		if (i >> j) % 2 == 1:
			kari += A[j][0]
			for k in range(M):
				s[k] += A[j][k + 1]
	if min(s) >= X:
		ans = min(ans, kari)
if ans == 10 ** 7:
	ans = -1
print(ans)


(n, m, x) = map(int, input().split())
s = [list(map(int, input().split())) for _ in range(n)]
ans = 10000000
for i in range(2 ** n):
	bag = [0] * (m + 1)
	for j in range(n):
		if i >> j & 1:
			for _ in range(m + 1):
				bag[_] += s[j][_]
	if min(bag[1:]) >= x and ans > bag[0]:
		ans = bag[0]
if ans == 10000000:
	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)


import itertools
(n, m, x) = list(map(int, input().split()))
ans = 10 ** 18
A = [list(map(int, input().split())) for i in range(n)]
for (i, _) in enumerate(A, 1):
	for j in itertools.combinations(A, r=i):
		B = list(zip(*j))
		C = [sum(B[m]) for m in range(m + 1)]
		if len([i for i in C[1:] if i >= x]) == m:
			ans = min(ans, C[0])
print(ans) if ans != 10 ** 18 else print(-1)


(n, m, x) = map(int, input().split())
b = [list(map(int, input().split())) for _ in range(n)]
ans = 100000000
for i in range(1 << n):
	money = 0
	s = [0] * m
	for j in range(n):
		if i >> j & 1:
			money += b[j][0]
			for k in range(1, m + 1):
				s[k - 1] += b[j][k]
	if min(s) >= x:
		ans = min(ans, money)
if ans != 100000000:
	print(ans)
else:
	print(-1)


(n, m, x) = map(int, input().split())
bk = [list(map(int, input().split())) for _ in range(n)]
pr = 10 ** 7
for i in range(2 ** n):
	ef = [0] * (m + 1)
	for j in range(n):
		if i >> j & 1:
			ef = [p + q for (p, q) in zip(ef, bk[j])]
	for k in range(1, m + 1):
		if ef[k] < x:
			break
		if k == m:
			pr = min(pr, ef[0])
print(pr if pr != 10 ** 7 else -1)


(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())
a = [list(map(int, input().split())) for _ in range(n)]
ans = 10 ** 18
for i in range(1 << n):
	rikai = [0] * m
	money = 0
	for j in range(n):
		if i & 1 << j:
			money += a[j][0]
			for k in range(1, m + 1):
				rikai[k - 1] += a[j][k]
	ok = True
	for r in rikai:
		if r < x:
			ok = False
			break
	if ok:
		ans = min(money, ans)
if ans == 10 ** 18:
	print(-1)
else:
	print(ans)


(n, m, x) = map(int, input().split())
li = [list(map(int, input().split())) for _ in range(n)]
ans = 10 ** 10
for b in range(2 ** n):
	skils = [0] * m
	tmp = 0
	for i in range(n):
		if b & 1 << i:
			for j in range(m):
				skils[j] += li[i][j + 1]
			tmp += li[i][0]
	if min(skils) >= x:
		ans = min(ans, tmp)
if ans == 10 ** 10:
	print(-1)
	exit()
print(ans)


(n, m, x) = map(int, input().split())
ca = [list(map(int, input().split())) for _ in range(n)]
ans = 10 ** 9
for i in range(2 ** n):
	cnt = [0] * m
	kari = 0
	for j in range(n):
		if i >> j & 1:
			for k in range(m):
				cnt[k] += ca[j][k + 1]
			kari += ca[j][0]
		else:
			pass
	if min(cnt) >= x:
		ans = min(ans, kari)
if ans == 10 ** 9:
	print(-1)
else:
	print(ans)


(N, M, X) = map(int, input().split())
A = []
for i in range(N):
	temp = list(map(int, input().split()))
	A.append(temp)
uds = [0] * M
cost = 0
ans = -1
for bit in range(2 ** N):
	for i in range(N):
		if bit >> i & 1:
			cost += A[i][0]
			for j in range(M):
				uds[j] += A[i][j + 1]
	if min(uds) >= X:
		if ans == -1 or ans > cost:
			ans = cost
	cost = 0
	uds = [0] * M
print(ans)


(n, m, x) = map(int, input().split())
book = [0] * n
for i in range(0, n):
	book[i] = list(map(int, input().split()))
total = []
for i in range(2 ** n):
	cost = 0
	rikai = [0] * m
	for j in range(n):
		if i >> j & 1:
			for k in range(m):
				rikai[k] += book[j][k + 1]
			cost += book[j][0]
	if all((l >= x for l in rikai)):
		total.append(cost)
if total == []:
	print('-1')
else:
	print(min(total))


(N, M, X) = map(int, input().split())
CA = [list(map(int, input().split())) for i in range(N)]
ans = 10 ** 9
for i in range(1, 2 ** N):
	tmp = 0
	S = [0] * M
	for j in range(N):
		if (i >> j) % 2 == 1:
			tmp += CA[j][0]
			for k in range(M):
				S[k] += CA[j][k + 1]
		if min(S) >= X:
			ans = min(ans, tmp)
if ans == 10 ** 9:
	print(-1)
else:
	print(ans)


(n, m, x) = map(int, input().split())
l = [list(map(int, input().split())) for i in range(n)]
ans = []
for i in range(2 ** n):
	s = [0] * m
	c = 0
	for j in range(n):
		if i >> j & 1:
			for k in range(m):
				s[k] += l[j][k + 1]
			c += l[j][0]
	t = 0
	for j in range(m):
		if s[j] >= x:
			t += 1
	if t == m:
		ans.append(c)
print(min(ans) if ans != [] else -1)


(n, m, x) = map(int, input().split())
CA = [list(map(int, input().split())) for _ in range(n)]
res = 10 ** 7
for i in range(2 ** n):
	money = 0
	under = [0] * m
	for j in range(n):
		if i >> j & 1:
			money += CA[j][0]
			for k in range(m):
				under[k] += CA[j][k + 1]
	if min(under) >= x:
		res = min(res, money)
if res == 10 ** 7:
	print('-1')
else:
	print(res)


(N, M, X) = map(int, input().split())
A = [0] * N
for i in range(N):
	A[i] = list(map(int, input().split()))
cost = 100000 * 12
ans = -1
for i in range(2 ** N):
	total = [0] * M
	c = 0
	for j in range(N):
		if i >> j & 1:
			c += A[j][0]
			count = 0
			for k in range(M):
				total[k] += A[j][k + 1]
	if min(total) >= X:
		cost = min(cost, c)
		ans = cost
print(ans)


(N, M, X) = map(int, input().split())
C = []
A = []
for i 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):
	cost = 0
	tmp = [0] * M
	for j in range(N):
		if i >> j & 1 == 0:
			continue
		cost += C[j]
		l = 0
		for k in A[j]:
			tmp[l] += k
			l += 1
		if min(tmp) >= X:
			if ans == -1:
				ans = cost
			else:
				ans = min(ans, cost)
print(ans)


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


(n, m, x) = map(int, input().split())
l = [list(map(int, input().split())) for i in range(n)]
ans = float('INF')
for i in range(2 ** n):
	var = [a for a in range(n) if (i >> a) % 2]
	now = [0] * m
	y = 0
	for j in var:
		y += l[j][0]
		for h in range(m):
			now[h] += l[j][h + 1]
	if min(now) >= x:
		ans = min(ans, y)
print(ans) if ans != float('INF') else print(-1)


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) = 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())
A = []
for _ in range(n):
	A.append(list(map(int, input().split())))
yeen = []
for i in range(2 ** n):
	rikai = [0] * m
	yen = 0
	for j in range(n):
		if i >> j & 1:
			yen += A[j][0]
			for w in range(1, m + 1):
				rikai[w - 1] += A[j][w]
		if min(rikai) >= x:
			yeen.append(yen)
if yeen == []:
	print(-1)
else:
	print(min(yeen))


(n, m, x) = map(int, input().split())
A = [list(map(int, input().split())) for a in range(n)]
mi = [10 ** 7]
for i in range(2 ** n):
	und = [0] * m
	money = 0
	for j in range(n):
		if i >> j & 1:
			money += A[j][0]
			for u in range(m):
				und[u] += A[j][u + 1]
	if all((und[s] >= x for s in range(m))):
		mi.append(money)
print(min(mi) if min(mi) != 10 ** 7 else -1)


import itertools
(n, m, x) = map(int, input().split())
l = [list(map(int, input().split())) for i in range(n)]
costl = []
for p in itertools.product([0, 1], repeat=n):
	al = [0] * m
	cost = 0
	for i in range(n):
		if p[i] == 1:
			cost += l[i][0]
			for j in range(1, m + 1):
				al[j - 1] += l[i][j]
	if all((mm >= x for mm in al)):
		costl.append(cost)
print(min(costl) if len(costl) >= 1 else -1)


(N, M, X) = map(int, input().split())
CA = [list(map(int, input().split())) for _ in range(N)]
ans = 1000000000.0
for i in range(2 ** N):
	cnt = [0] * (M + 1)
	for j in range(N):
		if i >> j & 1:
			cnt = [x + y for (x, y) in zip(cnt, CA[j])]
	if len([i for i in cnt[1:] if i >= X]) == M:
		ans = min(ans, cnt[0])
print(ans if ans < 1000000000.0 else -1)


(n, m, x) = map(int, input().split())
l = [list(map(int, input().split())) for i in range(n)]
ans = 10 ** 9
for i in range(2 ** n):
	t_ans = 0
	us = [0 for j in range(m)]
	for k in range(n):
		if i >> k & 1:
			book = l[k]
			t_ans += book[0]
			for p in range(m):
				us[p] += book[p + 1]
	if all([q >= x for q in us]):
		ans = min(ans, t_ans)
print(ans if ans != 10 ** 9 else -1)


(n, m, x) = map(int, input().split())
c = [list(map(int, input().split())) for _ in range(n)]
ans = []
for i in range(2 ** n):
	price = 0
	und = [0 for _ in range(m)]
	for j in range(n):
		if i >> j & 1:
			price += c[j][0]
			for k in range(m):
				und[k] += c[j][k + 1]
	if all((und[i] >= x for i in range(m))):
		ans.append(price)
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)]
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)


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())
li = [list(map(int, input().split())) for _ in range(N)]
ans = float('inf')
for i in range(2 ** N):
	price = 0
	abil = [0] * M
	for j in range(N):
		if i >> j & 1:
			price += li[j][0]
			for k in range(1, M + 1):
				abil[k - 1] += li[j][k]
	if min(abil) >= X:
		ans = min(ans, price)
if ans == float('inf'):
	print(-1)
else:
	print(ans)


(n, m, x) = map(int, input().split())
C = [list(map(int, input().split())) for _ in range(n)]
import itertools as it
import math
cost = math.inf
for comb in it.chain(*(it.combinations(C, r) for r in range(1, n + 1))):
	(c, *a) = map(sum, zip(*comb))
	if min(a) >= x:
		cost = min(cost, c)
if cost is not math.inf:
	print(cost)
else:
	print(-1)


(N, M, X) = map(int, input().split())
CA = [list(map(int, input().split())) for i in range(N)]
m = []
A = []
ans = float('inf')
for i in range(1 << N):
	a = [0] * (M + 1)
	for j in range(N):
		if i >> j & 1:
			for (x, k) in enumerate(CA[j]):
				a[x] += k
	if all((a >= X for a in a[1:])):
		ans = min(ans, a[0])
print(-1 if ans == float('inf') else ans)


(n, m, x) = map(int, input().split())
ca = [list(map(int, input().split())) for _ in range(n)]
ans = 12 * 10 ** 6
for i in range(2 ** n):
	s = [0] * (m + 1)
	for j in range(n):
		if i >> j & 1 == 1:
			for k in range(m + 1):
				s[k] += ca[j][k]
	for j in range(1, m + 1):
		if s[j] < x:
			break
	else:
		ans = min(ans, s[0])
print(-1 if ans == 12 * 10 ** 6 else ans)


(n, m, x) = map(int, input().split())
ca = [list(map(int, input().split())) for _ in range(n)]
ans = 10 ** 111
ok = False
for i in range(2 ** n):
	y = [0] * (m + 1)
	for j in range(n):
		if i & 1 << j:
			for k in range(m + 1):
				y[k] = y[k] + ca[j][k]
	if sum((z >= x for z in y[1:])) == m:
		ans = min(ans, y[0])
		ok = True
if ok:
	print(ans)
else:
	print(-1)


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)


(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:
			for k in range(M):
				s[k] += a[j][k + 1]
			c += a[j][0]
	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) = map(int, input().split())
C = []
A = []
for i in range(N):
	L = list(map(int, input().split()))
	C.append(L[0])
	A.append(L[1:])
res = -1
for i in range(1 << N):
	und = [0] * M
	cost = 0
	for j in range(N):
		if i >> j & 1 == 0:
			continue
		cost += C[j]
		for k in range(M):
			und[k] += A[j][k]
		if min(und) >= X:
			if res == -1:
				res = cost
			else:
				res = min(res, cost)
print(res)


(N, M, X) = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(N)]
ans = float('inf')
for mask in range(1, 1 << N):
	tmp = [0] * M
	money = 0
	for i in range(N):
		if mask >> i & 1:
			for j in range(M):
				tmp[j] += A[i][j + 1]
			money += A[i][0]
	if min(tmp) >= X:
		ans = min(ans, money)
if ans == float('inf'):
	print(-1)
else:
	print(ans)


(N, M, X) = map(int, input().split())
books = [list(map(int, input().split())) for _ in range(N)]
ans = -1
for bits in range(1 << N):
	cost = 0
	a = [0] * M
	for i in range(N):
		if bits >> i & 1 == 1:
			cost += books[i][0]
			for j in range(M):
				a[j] += books[i][j + 1]
	if min(a) >= X:
		ans = min(cost, ans) if ans >= 0 else cost
print(ans)


(n, m, x) = map(int, input().split())
mt = [list(map(int, input().split())) for i in range(n)]
res = [-1] * (m + 1)
temp = [0] * (m + 1)
for i in range(1 << n):
	for j in range(n):
		if i >> j & 1:
			for k in range(m + 1):
				temp[k] += mt[j][k]
	for j in range(1, m + 1):
		if temp[j] < x:
			break
	else:
		if res[0] > temp[0] or res[0] < 0:
			res = temp
	temp = [0] * (m + 1)
print(res[0])


(n, m, x) = map(int, input().split())
ca = [list(map(int, input().split())) for _ in range(n)]
res = float('inf')
for i in range(2 ** n):
	sc = 0
	a = [0] * m
	for j in range(n):
		if i >> j & 1:
			sc += ca[j][0]
			for k in range(m):
				a[k] += ca[j][k + 1]
	if min(a) >= x:
		res = min(sc, res)
if res == float('inf'):
	print(-1)
else:
	print(res)


(n, m, x) = map(int, input().split())
A = [list(map(int, input().split())) for j in range(n)]
ans = 10 ** 7
for i in range(1 << n):
	s = [0] * (m + 1)
	for j in range(n):
		if i >> j & 1:
			for k in range(m + 1):
				s[k] += A[j][k]
	if min(s[1:]) >= x:
		ans = min(ans, s[0])
print(-1) if ans == 10 ** 7 else 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()


(N, M, X) = map(int, input().split())
L = []
ans = [0] * (M + 1)
A = float('inf')
for i in range(N):
	L.append(list(map(int, input().split())))
for i in range(N):
	for j in range(1, M + 1):
		ans[j] += L[i][j]
if min(ans[1:M + 1]) < X:
	print(-1)
	exit()
for i in range(1, 2 ** N + 1):
	ans = [0] * (M + 1)
	i += 8192
	for j in range(N):
		if i >> j & 1:
			for k in range(M + 1):
				ans[k] += L[j][k]
	if min(ans[1:M + 1]) >= X:
		A = min(ans[0], A)
print(A)


(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()])
mcost = 10 ** 10
for i in range(2 ** N):
	learn = [0] * M
	cost = 0
	bn = str(bin(i))[2:].zfill(N)
	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()
	if learn[0] >= X:
		mcost = min(mcost, cost)
if mcost == 10 ** 10:
	mcost = -1
print(mcost)


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)


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
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) = map(int, input().split())
CA = [list(map(int, input().split())) for _ in range(n)]
ans = 10 ** 9
for i in range(2 ** n):
	ls = [0] * m
	tmp = 0
	for j in range(n):
		if i >> j & 1:
			ls = [l + a for (l, a) in zip(ls, CA[j][1:])]
			tmp += CA[j][0]
	if all((i >= x for i in ls)):
		ans = min(ans, tmp)
print(ans if ans != 10 ** 9 else -1)


(n, m, x) = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
ans = float('inf')
for i in range(1 << n):
	arr = [0] * (m + 1)
	for j in range(n):
		if i & 1 << j == 0:
			continue
		for (k, l) in enumerate(a[j]):
			arr[k] += l
	if all((l >= x for l in arr[1:])):
		ans = min(ans, arr[0])
print(-1 if ans == float('inf') else ans)


import sys
input = sys.stdin.buffer.readline
(n, m, x) = map(int, input().split())
c = []
a = []
for _ in range(n):
	(s, *t) = map(int, input().split())
	c.append(s)
	a.append(t)
ans = float('inf')
for i in range(2 ** n):
	l = [[0] * m]
	need = 0
	for j in range(n):
		if i & 1 << j:
			l.append(a[j])
			need += c[j]
	if all((sum(t) >= x for t in zip(*l))):
		ans = min(ans, need)
print(ans if ans != float('inf') else -1)


(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:])
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)


[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)
INF = 10 ** 10
min_cost = INF
for b in range(2 ** N):
	cost = 0
	algo_level = [0] * M
	for i in range(N):
		if b >> i & 1:
			cost += C[i]
			for a in range(M):
				algo_level[a] += A[i][a]
	if min(algo_level) >= X:
		min_cost = min(cost, min_cost)
if min_cost < INF:
	print(min_cost)
else:
	print('-1')


from operator import add
(n, m, x) = map(int, input().split())
l = [list(map(int, input().split())) for _ in range(n)]
ans = float('inf')
for i in range(2 ** n):
	c = 0
	s = [0] * m
	for b in range(n):
		if i >> b & 1:
			c += l[b][0]
			for j in range(m):
				s[j] += l[b][j + 1]
	if all([e >= x for e in s]):
		ans = min(ans, c)
if ans == float('inf'):
	ans = -1
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) = map(int, input().split())
a = [list(map(int, input().split())) for i in range(n)]
ans = 10000000000000000000000
for i in range(2 ** n):
	l = [0] * m
	c = 0
	for j in range(n):
		if i >> j & 1:
			aj = a[j]
			c += aj[0]
			for k in range(m):
				l[k] += aj[k + 1]
	if all([i >= x for i in l]):
		ans = min(ans, c)
if ans == 10000000000000000000000:
	print(-1)
else:
	print(ans)


import copy
(N, M, X) = map(int, input().split())
A = [0] * N
for i in range(N):
	A[i] = [int(x) for x in input().split()]

def nap(p, q):
	if q == N:
		if min(p[1:M + 1]) >= X:
			lity[-1] = min(lity[-1], p[0])
		return
	nap(copy.copy(p), q + 1)
	for i in range(M + 1):
		p[i] = p[i] + A[q][i]
	nap(copy.copy(p), q + 1)
lity = []
lity.append(10 ** 9)
r = [0] * (M + 1)
nap(r, 0)
if lity[-1] == 10 ** 9:
	print(-1)
else:
	print(lity[-1])


(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) = map(int, input().split())
CA = [list(map(int, input().split())) for i in range(N)]
ans = float('inf')
for b in range(1 << N):
	arr = [0] * (M + 1)
	for i in range(N):
		if b & 1 << i == 0:
			continue
		for (j, v) in enumerate(CA[i]):
			arr[j] += v
	if all((v >= X for v in arr[1:])):
		ans = min(ans, arr[0])
print(-1 if ans == float('inf') else 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()


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) = map(int, input().split())
ca = [list(map(int, input().split())) for i in range(n)]
ans = 10 ** 18
for i in range(2 ** n):
	algo = [0] * m
	cost = 0
	for j in range(n):
		if i >> j & 1:
			book = ca[j]
			cost += book[0]
			for (k, v) in enumerate(book[1:]):
				algo[k] += v
	if all([j >= x for j in algo]):
		ans = min(ans, cost)
if ans == 10 ** 18:
	print(-1)
else:
	print(ans)


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


(N, M, X) = map(int, input().split())
c = []
a = []
for i in range(N):
	(c_temp, *a_temp) = list(map(int, input().split()))
	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:
			price_total += c[j]
			learn = a[j]
			for (k, la) in enumerate(learn):
				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 itertools
(N, M, X) = map(int, input().split())
a = [list(map(int, input().split())) for i in range(N)]
nums = [0, 1]
c = float('inf')
for balls in itertools.product(nums, repeat=N):
	g = 1
	for j in range(M):
		if X > sum([balls[i] * a[i][j + 1] for i in range(N)]):
			g = 0
	if g == 1:
		c = min(c, sum([balls[i] * a[i][0] for i in range(N)]))
if c != float('inf'):
	print(c)
else:
	print(-1)


(N, M, X) = map(int, input().split())
A = [list(map(int, input().split())) for i in range(N)]
C = 10 ** 7
for i in range(2 ** N):
	(P, T) = ([0] * M, 0)
	for j in range(N):
		if i & 2 ** j:
			T += A[j][0]
			for k in range(M):
				P[k] += A[j][k + 1]
	for j in range(M):
		if P[j] < X:
			break
	else:
		C = min(C, T)
print(-1 if C == 10 ** 7 else C)


(n, m, x) = map(int, input().split())
c = []
a = []
for _ in range(n):
	ca = list(map(int, input().split()))
	c.append(ca[0])
	a.append(ca[1:])
ans = 13 * pow(10, 5)
for i in range(2 ** n):
	rikai = [0] * m
	kin = 0
	for j in range(n):
		if i >> j & 1:
			for k in range(m):
				rikai[k] += a[j][k]
			kin += c[j]
	if min(rikai) >= x:
		ans = min(ans, kin)
print(ans if ans < 13 * pow(10, 5) else -1)


(n, m, x) = map(int, input().split())
l = []
for i in range(n):
	l.append(list(map(int, input().split())))
s = []
a = [0] * (m + 1)
s.append(a)
for i in range(n):
	newl = []
	for j in s:
		new = [j[k] + l[i][k] for k in range(m + 1)]
		newl.append(new)
	s.extend(newl)
ans = float('inf')
for i in s:
	for j in range(m):
		if i[j + 1] < x:
			break
	else:
		ans = min(ans, i[0])
if ans == float('inf'):
	print(-1)
else:
	print(ans)


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)


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) = map(int, input().split())
L = []
sum = 0
for i in range(n):
	S = list(map(int, input().split()))
	L.append(S)
	sum += S[0]
import itertools
f = 0
ans = sum
for i in itertools.product((1, 0), repeat=n):
	X = [0] * (m + 1)
	for j in range(n):
		if i[j] == 1:
			for k in range(m + 1):
				X[k] += L[j][k]
	if min(X[1:]) >= x:
		ans = min(ans, X[0])
		f += 1
if f == 0:
	print(-1)
else:
	print(ans)


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

def python_list_add(in1, in2):
	return [a + b for (a, b) in zip(in1, in2)]
A = []
for i in range(N):
	A.append(list(map(int, input().split())))
m = 1000000000.0
for i in range(2 ** N):
	total = [0] * (M + 1)
	for j in range(N):
		if i >> j & 1:
			total = python_list_add(total, A[j])
	if all((elem >= X for elem in total[1:])):
		m = min(total[0], m)
if m == 1000000000.0:
	m = -1
print(m)


(n, m, x) = map(int, input().split())
ans = 999999999999999999
a = [0] * n
for i in range(n):
	a[i] = list(map(int, input().split()))
for i in range(2 ** n):
	t = [0] * m
	temp = 0
	for j in range(n):
		if i >> j & 1:
			temp = temp + a[j][0]
			for k in range(m):
				t[k] = t[k] + a[j][k + 1]
	if min(t) >= x:
		ans = min(ans, temp)
if ans == 999999999999999999:
	print(-1)
else:
	print(ans)


(N, M, X) = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(N)]
ans = 10 ** 9 + 10
for i in range(1, 2 ** N):
	money = 0
	L = [0] * M
	for j in range(N):
		if i >> j & 1:
			money += A[j][0]
			for k in range(M):
				L[k] += A[j][k + 1]
	if min(L) >= X and money < ans:
		ans = money
if ans == 10 ** 9 + 10:
	ans = -1
print(ans)


(N, M, X) = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(N)]
ans = 10 ** 20
for bit in range(2 ** N):
	C = [0] * M
	cost = 0
	for i in range(N):
		if bit >> i & 1 == 1:
			cost += A[i][0]
			for j in range(1, M + 1):
				C[j - 1] += A[i][j]
	if min(C) >= X:
		ans = min(ans, cost)
print(ans if ans != 10 ** 20 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')
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]
	for levels in levels_sum:
		if levels < level:
			flag = 1
			break
	if flag == 0 and ans > price_sum:
		ans = price_sum
if ans != float('inf'):
	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)


(n, m, x) = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
INF = 99999999999
ans = INF
for i in range(2 ** n):
	tans = 0
	c = [0] * m
	for j in range(n):
		if i >> j & 1:
			tans += a[j][0]
			for k in range(m):
				c[k] += a[j][k + 1]
	if min(c) >= x:
		ans = min(tans, ans)
if ans == INF:
	print(-1)
else:
	print(ans)


(n, m, x) = map(int, input().split())
L = []
for i in range(n):
	A = list(map(int, input().split()))
	L.append(A)
C = 10 ** 7
for i in range(1 << n):
	c = 0
	R = [0] * m
	for j in range(n):
		if i & 1 << j:
			c += L[j][0]
			for k in range(m):
				R[k] += L[j][k + 1]
	if min(R) >= x:
		C = min(c, C)
if C == 10 ** 7:
	print(-1)
else:
	print(C)


(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) = 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) = map(int, input().split())
ca = [list(map(int, input().split())) for _ in range(n)]
ans = []
for i in range(2 ** n):
	jud = [0] * m
	money = 0
	for j in range(n):
		if i >> j & 1:
			money += ca[j][0]
			for k in range(m):
				jud[k] += ca[j][k + 1]
	if min(jud) >= x:
		ans.append(money)
if not ans:
	print(-1)
else:
	print(min(ans))


(n, m, x) = map(int, input().split())
a = []
for _ in range(n):
	s = list(map(int, input().split()))
	a.append(s)
ans = []
check = 0
for q in range(2 ** n):
	nedan = [0] * m
	sum1 = 0
	for i in range(n):
		if q >> i & 1:
			sum1 += a[i][0]
			for p in range(m):
				nedan[p] += a[i][p + 1]
	t = min(nedan)
	if t >= x:
		ans.append(sum1)
		check += 1
if check == 0:
	print(-1)
else:
	print(min(ans))


(N, M, X) = map(int, input().split())
CA = list((list(map(int, input().split())) for _ in range(N)))
cost = 10 ** 5 * 12
for i in range(2 ** N):
	(total, a) = (0, [0] * M)
	for j in range(N):
		if i >> j & 1:
			total += CA[j][0]
			for k in range(M):
				a[k] += CA[j][k + 1]
	for j in range(M):
		if a[j] < X:
			if i == 2 ** N - 1:
				cost = -1
			break
	else:
		cost = min(cost, total)
print(cost)


mod = 1000000007
(n, m, x) = map(int, input().split())
w = []
for i in range(n):
	w.append([int(i) for i in input().split()])
ans = mod
for i in range(2 ** n):
	d = 0
	chk = [0] * m
	for j in range(n):
		if i >> j & 1:
			d += w[j][0]
			for k in range(m):
				chk[k] += w[j][k + 1]
	if min(chk) >= x:
		ans = min(ans, d)
print(ans if ans != mod else -1)


(n, m, x) = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
ans = 1000000000000000.0
for f in range(1 << n):
	(p, c) = ([0] * m, 0)
	for i in range(n):
		if f % 2:
			p = list(map(lambda x, y: x + y, p, a[i][1:]))
			c += a[i][0]
		f //= 2
	if all((p[i] >= x for i in range(m))):
		ans = min(ans, c)
print(-1 if ans >= 1000000000000000.0 else ans)


from itertools import *
(n, m, x) = map(int, input().split())
L = [list(map(int, input().split())) for _ in range(n)]
a = 10 ** 7
for i in range(1, n + 1):
	for j in combinations(L, i):
		b = [0] * (m + 1)
		for k in j:
			b = [b[i] + k[i] for i in range(m + 1)]
		if all((i >= x for i in b[1:])):
			a = min(a, b[0])
print(-1 if a == 10 ** 7 else a)


import itertools
(N, M, X) = map(int, input().split())
C = [list(map(int, input().split())) for n in range(N)]
cost = 10 ** 9
for com in itertools.chain(*(itertools.combinations(C, r) for r in range(1, N + 1))):
	(c, *a) = map(sum, zip(*com))
	if c < cost and X <= min(a):
		cost = c
if cost == 10 ** 9:
	print(-1)
else:
	print(cost)


(N, M, X) = map(int, input().split())
C = [list(map(int, input().split())) for _ in range(N)]
L = []
for i in range(2 ** N):
	A = [0 for _ in range(M + 1)]
	for j in range(N):
		if i & 1 << j:
			for k in range(M + 1):
				A[k] += C[j][k]
	flag = True
	for i in range(M):
		if A[i + 1] < X:
			flag = False
	if flag:
		L.append(A[0])
if L == []:
	L.append(-1)
print(min(L))


(n, m, x) = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(n)]
a = float('inf')
for i in range(2 ** n):
	S = [0] * (m + 1)
	for j in range(n):
		if i >> j & 1:
			S = [S[k] + A[j][k] for k in range(m + 1)]
	if all([s >= x for s in S[1:]]):
		a = min(a, S[0])
print(-1 if a == float('inf') else a)


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


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


(n, m, x) = map(int, input().split())
ca = [list(map(int, input().split())) for _ in range(n)]
ans = [-1] * (m + 1)
tmp = [0] * (m + 1)
for i in range(2 ** n):
	for j in range(n):
		if i >> j & 1:
			for k in range(m + 1):
				tmp[k] += ca[j][k]
	for j in range(1, m + 1):
		if tmp[j] < x:
			break
	else:
		if ans[0] > tmp[0] or ans[0] < 0:
			ans = tmp
	tmp = [0] * (m + 1)
print(ans[0])


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 j in combinations(ca, i):
		l = [0] * (m + 1)
		for k in j:
			for i2 in range(m + 1):
				l[i2] += k[i2]
		if all((l[num] >= x for num in range(1, m + 1))):
			ans = min(ans, l[0])
if ans == float('inf'):
	print(-1)
else:
	print(ans)


(N, M, X) = map(int, input().split())
B = [list(map(int, input().split())) for i in range(N)]
ANS = 1 << 60
for i in range(1 << N):
	SCORE = [0] * M
	MONEY = 0
	for j in range(N):
		if 1 << j & i != 0:
			MONEY += B[j][0]
			for k in range(M):
				SCORE[k] += B[j][k + 1]
	if min(SCORE) >= X:
		ANS = min(ANS, MONEY)
if ANS == 1 << 60:
	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):
	A_sum = [0] * M
	C_sum = 0
	for j in range(N):
		if i >> j & 1 == 0:
			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)):
		if ans == -1:
			ans = C_sum
		else:
			ans = min(ans, C_sum)
print(ans)


(N, M, X) = map(int, input().split())
ls = [list(map(int, input().split())) for i in range(N)]
ls_c = []
for i in range(1, 2 ** N):
	ls_al = [0] * M
	c = 0
	for j in range(N):
		if i >> j & 1 == 1:
			c += ls[j][0]
			for k in range(M):
				ls_al[k] += ls[j][k + 1]
	if min(ls_al) >= X:
		ls_c.append(c)
if ls_c != []:
	print(min(ls_c))
else:
	print(-1)


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\n60 2 2 4\n70 8 7 9\n50 2 3 9'
		output = '120'
		self.assertIO(input, output)

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

	def test_入力例_3(self):
		input = '8 5 22\n100 3 7 5 3 1\n164 4 5 2 7 8\n334 7 2 7 2 9\n234 4 7 2 8 2\n541 5 4 3 3 6\n235 4 8 6 9 7\n394 3 6 1 6 2\n872 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():
	resolve()
__starting_point()


(n, m, x) = map(int, input().split())
cc = [list(map(int, input().split())) for _ in range(n)]
ans = float('inf')
for b in range(1 << n):
	a = [0] * (m + 1)
	for i in range(n):
		if b & 1 << i == 0:
			continue
		for (k, l) in enumerate(cc[i]):
			a[k] += l
		if min(a[1:]) >= x:
			ans = min(ans, a[0])
	a = [0] * (m + 1)
if ans == float('inf'):
	print(-1)
else:
	print(ans)


(n, m, x) = map(int, input().split())
ca = [list(map(int, input().split())) for _ in range(n)]
c = [0] * n
ans = 10 ** 7
for i in range(n):
	c[i] = ca[i][0]
for i in range(2 ** n):
	l = [0] * m
	prime = 0
	for j in range(n):
		if i >> j & 1:
			prime += c[j]
			for k in range(m):
				l[k] += ca[j][k + 1]
	if all([j >= x for j in l]):
		ans = min(ans, prime)
print(-1 if ans == 10 ** 7 else 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)


(N, M, X) = map(int, input().split())
li = [list(map(int, input().split())) for _ in range(N)]
ans = float('inf')
for i in range(2 ** N):
	PriceAbil = [0] * (M + 1)
	for j in range(N):
		if i >> j & 1:
			PriceAbil = [x + y for (x, y) in zip(PriceAbil, li[j])]
	if min(PriceAbil[1:]) >= X:
		ans = min(ans, PriceAbil[0])
if ans == float('inf'):
	print(-1)
else:
	print(ans)


(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):
	sum = 0
	unst = list(map(all0, unst))
	for j in range(N):
		if i >> j & 1:
			sum += B[j][0]
			for k in range(M):
				unst[k] += B[j][k + 1]
	if all((elem >= X for elem in unst)):
		sum_ok = sum
		flg = 1
	x = min(x, sum_ok)
if flg == 0:
	print(-1)
else:
	print(x)


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) = map(int, input().split())
C = [list(map(int, input().split())) for _ in range(N)]
ans = inf = float('inf')

def dfs(idx, tt, l):
	global ans
	for i in range(idx, N):
		ntt = tt + C[i][0]
		nl = [l[j] + C[i][j + 1] for j in range(M)]
		for x in nl:
			if x < X:
				break
		else:
			ans = min(ans, ntt)
		dfs(i + 1, ntt, nl)
dfs(0, 0, [0] * M)
print(ans if ans < inf else -1)


(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 = [0] * n
a = [[]] * n
for i in range(n):
	(c[i], *a[i]) = map(int, input().split())
ans = 2 ** 32
for mask in range(1 << n):
	res = [0] * m
	cost = 0
	for i in range(n):
		if mask >> i & 1:
			cost += c[i]
			for j in range(m):
				res[j] += a[i][j]
	if all((v >= x for v in res)):
		ans = min(ans, cost)
print(ans if ans != 2 ** 32 else -1)


(N, M, X) = map(int, input().split())
arr = [list(map(int, input().split())) for _ in range(N)]
ans = float('inf')
for paint_h in range(2 ** N):
	temp_arr = [0] * (M + 1)
	for i in range(N):
		if paint_h >> i & 1 == 1:
			temp_arr = [a + b for (a, b) in zip(temp_arr, arr[i])]
	if all((i >= X for i in temp_arr[1:])):
		ans = min(ans, temp_arr[0])
print(ans if ans != float('inf') else -1)


(n, m, x) = map(int, input().split())
a = []
ans = -1
t = [0] * (m + 1)
for i in range(n):
	a.append(list(map(int, input().split())))
for i in range(2 ** n):
	for j in range(n):
		if i >> j & 1:
			for (lnd, l) in enumerate(a[j]):
				t[lnd] += l
	if ans == -1 or ans > t[0]:
		if min(t[1:m + 1]) >= x:
			ans = t[0]
	t = [0] * (m + 1)
print(ans)


([n, m, x], *t) = [[*map(int, t.split())] for t in open(0)]
ans = 1200001
for i in range(1, 2 ** n):
	tmp = [t[k] for k in range(n) if 1 << k & i]
	(c, *a) = map(sum, zip(*tmp))
	if min(a) >= x:
		ans = min(ans, c)
if ans == 1200001:
	print(-1)
else:
	print(ans)


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


(N, M, X) = map(int, input().split())
A = [[int(x) for x in input().split()] for _ in range(N)]
INF = float('inf')
ans = INF
for i in range(2 ** N):
	tmp = [0 for _ in range(M + 1)]
	b = bin(i)[2:].zfill(N)
	for n in range(N):
		for m in range(M + 1):
			tmp[m] += A[n][m] * int(b[N - 1 - n])
	if min(tmp[1:]) >= X:
		ans = min(ans, tmp[0])
if ans == INF:
	ans = -1
print(ans)


(n, m, x) = (int(x) for x in input().split())
la = []
for i in range(n):
	la.append(list(map(int, input().split())))
y = 0
for i in range(2 ** n):
	lb = [0] * (m + 1)
	for j in range(n):
		if i >> j & 1:
			lb = [x + y for (x, y) in zip(lb, la[j][:])]
	frg = 1
	for h in range(m):
		if lb[h + 1] < x:
			frg = 0
	if frg == 1:
		if lb[0] <= y or y == 0:
			y = lb[0]
	del lb[:]
print(y if y > 0 else -1)


(n, m, x) = map(int, input().split())
book = [list(map(int, input().split())) for i in range(n)]
ans = 10 ** 7
for i in range(2 ** n):
	l = [0] * (m + 1)
	for j in range(n):
		if i >> j & 1:
			for k in range(m + 1):
				l[k] += book[j][k]
		if all((l[i] >= x for i in range(1, m + 1))):
			if l[0] < ans:
				ans = l[0]
if ans == 10 ** 7:
	print(-1)
else:
	print(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()


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


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())
A = [list(map(int, input().split())) for _ in range(N)]
ans = float('inf')
for i in range(1 << N):
	tmp = [0] * (M + 1)
	for j in range(N):
		if i & 1 << j == 0:
			continue
		for (k, l) in enumerate(A[j]):
			tmp[k] += l
	if all((e >= X for e in tmp[1:])):
		ans = min(ans, tmp[0])
if ans == float('inf'):
	ans = -1
print(ans)


(n, m, x) = map(int, input().split())
book_list = [list(map(int, input().split())) for _ in range(n)]
ans = -1
for i in range(2 ** n):
	result = [0] * (m + 1)
	for j in range(n):
		if i >> j & 1:
			for k in range(m + 1):
				result[k] += book_list[j][k]
	if min(result[1:m + 1]) >= x:
		if ans == -1:
			ans = result[0]
		else:
			ans = min(ans, result[0])
print(ans)


(N, M, X) = map(int, input().split())
B = [list(map(int, input().split())) for k in range(N)]
ans = float('inf')
for k in range(2 ** N):
	p = 0
	t = [0] * M
	for d in range(N):
		if k >> d & 1 == 1:
			p += B[d][0]
			for l in range(1, M + 1):
				t[l - 1] += B[d][l]
	if min(t) >= X:
		ans = min(ans, p)
if ans == float('inf'):
	print(-1)
else:
	print(ans)


(N, M, X) = map(int, input().split())
B = [list(map(int, input().split())) for _ in range(N)]
inf = 10 ** 5 * 12 + 1
ans = inf
for i in range(1, 2 ** N):
	tmp = [0] * M
	c = 0
	for j in range(N):
		if i >> j & 1:
			for k in range(M):
				tmp[k] += B[j][k + 1]
			c += B[j][0]
	if len([i for i in tmp if i >= X]) == M:
		ans = min(c, ans)
print(ans if ans < inf else -1)


from itertools import product as prod
(N, M, X) = map(int, input().split())
B = [list(map(int, input().split())) for _ in range(N)]
ans = float('INF')
for v in prod(range(2), repeat=N):
	scores = [0] * M
	cost = 0
	for i in range(N):
		if v[i] == 1:
			cost += B[i][0]
			for j in range(M):
				scores[j] += B[i][1 + j]
	if min(scores) >= X:
		ans = min(ans, cost)
print(ans if ans != float('INF') else -1)


(n, m, x) = map(int, input().split())
a = []
for i in range(n):
	b = list(map(int, input().split()))
	a.append(b)
l = []
for f in range(2 ** n):
	p = [0] * (m + 1)
	for i in range(n):
		if bin(f >> i)[-1] == '1':
			for j in range(m + 1):
				p[j] += a[i][j]
	if min(p[1:]) >= x:
		l.append(p[0])
if len(l) == 0:
	print('-1')
else:
	print(min(l))


from itertools import *
(n, m, x) = map(int, input().split())
d = [list(map(int, input().split())) for k in range(n)]
INF = float('inf')
mi = INF
for i in range(1, n + 1):
	for j in combinations(range(n), i):
		if all((sum((d[p][q] for p in j)) >= x for q in range(1, m + 1))):
			mi = min(mi, sum((d[c][0] for c in j)))
print(mi if mi != INF else -1)


(N, M, X) = map(int, input().split())
l = [list(map(int, input().split())) for i in range(N)]
cmin = 12 * 10 ** 5 + 1
for bit in range(2 ** N):
	A = [0] * M
	c = 0
	for j in range(N):
		if bit >> j & 1:
			c += l[j][0]
			A = [x + y for (x, y) in zip(A, l[j][1:])]
	if min(A) >= X:
		cmin = min(cmin, c)
if cmin != 12 * 10 ** 5 + 1:
	print(cmin)
else:
	print(-1)


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())
a = [list(map(int, input().split())) for i in range(n)]
ans = []
for bit in range(1 << n):
	total = 0
	skill = [0] * m
	for i in range(n):
		if bit & 1 << i:
			total += a[i][0]
			for j in range(m):
				skill[j] += a[i][j + 1]
	if all([k >= x for k in skill]):
		ans.append(total)
print(min(ans) if len(ans) != 0 else -1)


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, d) = map(int, input().split())
INF = 10 ** 18
c = [0] * n
a = []
for i in range(n):
	(c[i], *b) = list(map(int, input().split()))
	a.append(b)
ans = INF
for i in range(2 ** n):
	x = [0] * m
	cnt = 0
	for j in range(n):
		if i >> j & 1:
			cnt += c[j]
			for k in range(m):
				x[k] += a[j][k]
	for j in range(m):
		if x[j] < d:
			break
	else:
		ans = min(cnt, ans)
print(ans if ans != INF else -1)


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


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)
	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]
		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 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) = 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:
			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())
a = [list(map(int, input().split())) for _ in range(n)]
minc = float('inf')
for i in range(2 ** n):
	lst = [0] * (m + 1)
	for bit in range(n):
		if i >> bit & 1 == 1:
			for (ii, aa) in enumerate(a[bit]):
				lst[ii] += aa
	if min(lst[1:]) >= x:
		minc = min(minc, lst[0])
print(-1 if minc == float('inf') else minc)


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


(N, M, X) = map(int, input().split())
C = []
As = []
for _ in range(N):
	(c, *a) = map(int, input().split())
	C += [c]
	As += [a]
r = 1000000000.0
for i in range(2 ** N):
	cost = 0
	perf = [0] * M
	for j in range(N):
		if i >> j & 1:
			cost += C[j]
			perf = [perf[k] + As[j][k] for k in range(M)]
	if all((p >= X for p in perf)):
		r = min(r, cost)
if r == 1000000000.0:
	r = -1
print(r)


(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) = map(int, input().split())
ls = [list(map(int, input().split())) for i in range(n)]
ans = 10 ** 18
for i in range(2 ** n):
	uds = [0] * m
	cost = 0
	for j in range(n):
		if i & 1 << j:
			for k in range(m):
				uds[k] += ls[j][k + 1]
			cost += ls[j][0]
	if min(uds) >= x:
		ans = min(ans, cost)
if ans == 10 ** 18:
	print(-1)
else:
	print(ans)


(n, m, x) = map(int, input().split())
ca = []
ans = -1
for i in range(n):
	ca.append(list(map(int, input().split())))
for i in range(1 << n):
	suma = [0] * (m + 1)
	for j in range(n):
		if i >> j & 1:
			for k in range(m + 1):
				suma[k] += ca[j][k]
	chk = True
	for j in range(1, m + 1):
		if suma[j] < x:
			chk = False
			break
	if chk and (ans == -1 or ans > suma[0]):
		ans = suma[0]
print(ans)


import itertools
(N, M, X) = map(int, input().split())
B = [tuple(map(int, input().split())) for _ in range(N)]
MAX = 10 ** 7
ans = MAX
for t in itertools.product((0, 1), repeat=N):
	A = [sum((t[j] * B[j][i + 1] for j in range(N))) for i in range(M)]
	if all((a >= X for a in A)):
		ans = min(ans, sum((t[j] * B[j][0] for j in range(N))))
print(ans if ans != MAX else -1)


(n, m, x) = map(int, input().split())
CA = [list(map(int, input().split())) for _ in range(n)]
ans = 10 ** 21
for b in range(2 ** n):
	A = [0] * m
	c = 0
	for i in range(n):
		if 1 & b >> i:
			c += CA[i][0]
			for (itr, a) in enumerate(CA[i][1:]):
				A[itr] += a
	if all((a >= x for a in A)):
		ans = min(ans, c)
if ans == 10 ** 21:
	ans = -1
print(ans)


(n, m, x) = [int(x) for x in input().split()]
c = [[int(x) for x in input().split()] for _ in range(n)]
ans = float('inf')
for s in range(1 << n):
	if all((sum((c[i][j] for i in range(n) if s & 1 << i)) >= x for j in range(1, m + 1))):
		ans = min(ans, sum((c[i][0] for i in range(n) if s & 1 << i)))
print(ans if ans != float('inf') else -1)


(n, m, x) = map(int, input().split())
l = [list(map(int, input().split())) for i in range(n)]
ans = 10 ** 9
for i in range(2 ** n):
	t_ans = 0
	us = [0 for q in range(m)]
	for j in range(n):
		if i >> j & 1:
			use = l[j]
			t_ans += use[0]
			for w in range(m):
				us[w] += use[w + 1]
	check = 1
	for z in us:
		if z < x:
			check = 0
	if check == 1:
		ans = min(ans, t_ans)
print(ans if ans != 10 ** 9 else -1)


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


(n, m, x) = map(int, input().split())
c = [list(map(int, input().split())) for _ in range(n)]
ans = 9 ** 9
flag = False
for i in range(2 ** n):
	cost = 0
	a = [0] * m
	for j in range(n):
		if i >> j & 1:
			cost += c[j][0]
			for k in range(m):
				a[k] += c[j][k + 1]
	if min(a) >= x:
		flag = True
		ans = min(ans, cost)
print(ans if flag else -1)


(n, k, x) = map(int, input().split())
ll = [list(map(int, input().split())) for _ in [0] * n]
costl = []
for i in range(2 ** n):
	fmt = '0' + str(n) + 'b'
	s = format(i, fmt)
	suml = [0] * len(ll[0])
	for i in range(n):
		if s[i] == '1':
			for j in range(len(suml)):
				suml[j] += ll[i][j]
	if x <= min(suml[1:]):
		costl.append(suml[0])
print(min(costl) if len(costl) > 0 else -1)


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())
a = [list(map(int, input().split())) for _ in range(n)]
ans = 1e+18
for i in range(1 << n):
	b = [0] * m
	c = 0
	for j in range(n):
		if i & 1 << j:
			c += a[j][0]
			for k in range(m):
				b[k] += a[j][k + 1]
	for j in range(m):
		if b[j] < x:
			c = 1e+18
	ans = min(ans, c)
print(-1 if ans == 1e+18 else ans)


(n, m, x) = map(int, input().split())
c = []
a = []
for i in range(n):
	s = list(map(int, input().split()))
	b = s.pop(0)
	c.append(b)
	a.append(s)
ans = 10 ** 9
for i in range(2 ** n):
	cnt = 0
	b = [0 for i in range(m)]
	for j in range(n):
		if i >> j & 1:
			cnt += c[j]
			for k in range(m):
				b[k] += a[j][k]
	mn = min(b)
	if mn >= x:
		ans = min(ans, cnt)
if ans == 10 ** 9:
	print(-1)
else:
	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])


(n, m, x) = map(int, input().split())
c = [list(map(int, input().split())) for _ in range(n)]
ans = float('inf')
for i in range(2 ** n):
	data = [0] * (m + 1)
	for j in range(n):
		if i & 1 << j:
			for k in range(m + 1):
				data[k] += c[j][k]
		cnt = 0
		for l in range(1, m + 1):
			if data[l] >= x:
				cnt += 1
		if cnt == m:
			ans = min(ans, data[0])
if ans == float('inf'):
	print(-1)
	exit()
print(ans)


import sys
(N, M, X) = map(int, sys.stdin.readline().rstrip().split())
A = [list(map(int, sys.stdin.readline().rstrip().split())) for i in range(N)]
cost = []
for i in range(1 << N):
	l = [0] * (M + 1)
	for j in range(N):
		if i >> j & 1 == 1:
			l = [l[k] + A[j][k] for k in range(M + 1)]
	for k in range(M):
		if l[k + 1] < X:
			break
	else:
		cost.append(l[0])
cost.sort()
print(-1 if cost == [] else cost[0])


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


(N, M, X) = map(int, input().split())
book = [list(map(int, input().split())) for i in range(N)]
min_value = -1
for i in range(2 ** N):
	sum = [0 for k in range(M + 1)]
	for j in range(N):
		if i >> j & 1:
			sum = [x + y for (x, y) in zip(sum, book[j])]
	if min(sum[1:]) >= X and (min_value > sum[0] or min_value == -1):
		min_value = sum[0]
print(min_value)


(N, M, X) = 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):
		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)


(N, M, X) = map(int, input().split())
ca = [list(map(int, input().split())) for _ in range(N)]
ans = float('inf')
for i in range(2 ** N):
	tca = [0] * (M + 1)
	for j in range(N):
		if i & 1 << j > 0:
			for k in range(M + 1):
				tca[k] += ca[j][k]
	if min(tca[1:]) >= X:
		ans = min(ans, tca[0])
if ans != float('inf'):
	print(ans)
else:
	print(-1)


(n, m, x) = list(map(int, input().split()))
ca = []
ans = -1
for i in range(n):
	ca.append(list(map(int, input().split())))
for i in range(2 ** n):
	A_sum = [0] * m
	C_sum = 0
	for j in range(n):
		if i >> j & 1:
			C_sum += ca[j][0]
			for k in range(1, m + 1):
				A_sum[k - 1] += ca[j][k]
	if min(A_sum) >= x:
		if ans == -1:
			ans = C_sum
		elif C_sum < ans:
			ans = C_sum
print(ans)


(N, M, X) = map(int, input().split())
ls = []
for i in range(N):
	(C, *A) = map(int, input().split())
	ls.append((C, A))
ans = 10 ** 10
for i in range(2 ** N):
	used = [0] * M
	m = 0
	for j in range(N):
		if i % 2 == 0:
			(C, A) = ls[j]
			m += C
			for h in range(M):
				used[h] += A[h]
		i >>= 1
	if all((c >= X for c in used)):
		ans = min(ans, m)
if ans == 10 ** 10:
	print(-1)
else:
	print(ans)


(n, m, x) = map(int, input().split())
a = []
c = []
ma = [0] * m
for i in range(n):
	(cc, *aa) = map(int, input().split())
	a.append(aa)
	c.append(cc)
	for j in range(m):
		ma[j] += aa[j]
if min(ma) < x:
	exit(print(-1))
ans = sum(c)
for i in range(1, 1 << n):
	f = [0] * m
	cc = 0
	for j in range(n):
		if i & 1 << j:
			cc += c[j]
			for k in range(m):
				f[k] += a[j][k]
	if min(f) >= x:
		ans = min(ans, cc)
print(ans)


(N, M, X) = map(int, input().split())
lst = [0] * N
for i in range(N):
	lst[i] = list(map(int, input().split()))
x = -1

def ad(l1, l2):
	n = len(l1)
	return [l1[i] + l2[i] for i in range(n)]
for i in range(2 ** N):
	l0 = [0] * (M + 1)
	for j in range(N):
		if i // 2 ** j % 2:
			l0 = ad(l0, lst[j])
	if sum([j >= X for j in l0[1:]]) == M:
		if l0[0] <= x or x == -1:
			x = l0[0]
print(x)


def main():
	(n, m, x) = map(int, input().split(' '))
	ca = []
	a = []
	c = []
	INF = 10000000.0
	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()


(N, M, X) = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(N)]
ans = 10 ** 20
for mask in range(2 ** N):
	C = [0] * M
	cst = 0
	for i in range(N):
		if mask >> i & 1:
			cst += x[i][0]
			for j in range(1, M + 1):
				C[j - 1] += x[i][j]
	if min(C) >= X:
		ans = min(ans, cst)
if ans < 10 ** 20:
	print(ans)
else:
	print(-1)


(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, X) = map(int, input().split())
data = [list(map(int, input().split())) for _ in range(N)]
cand = []
for i in range(2 ** N):
	ps = [0] * (M + 1)
	for j in range(N):
		if i >> j & 1:
			for (idx, x) in enumerate(data[j]):
				ps[idx] += x
	if all([x >= X for x in ps[1:]]):
		cand.append(ps[0])
if len(cand) == 0:
	print(-1)
else:
	print(min(cand))


(N, M, X) = list(map(int, input().split()))
lis = []
for i in range(N):
	CA = list(map(int, input().split()))
	lis.append(CA)
ans = 1000000000.0
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 == 1000000000.0:
	print(-1)
else:
	print(ans)


(N, M, X) = map(int, input().split())
CA = [list(map(int, input().split())) for _ in [0] * N]
INF = 10 ** 5 * 100
ans = INF
for i in range(2 ** N):
	tmp = 0
	B = [0] * M
	for j in range(N):
		if i >> j & 1 == 0:
			continue
		tmp += CA[j][0]
		for (k, a) in enumerate(CA[j][1:]):
			B[k] += a
	if min(B) >= X:
		ans = min(ans, tmp)
if ans == INF:
	ans = -1
print(ans)


(n, m, x) = map(int, input().split())
c = [list(map(int, input().split())) for i in range(n)]
ans = 10 ** 7
for i in range(1, 2 ** n):
	temp = [0] * (m + 1)
	for j in range(n):
		if i >> j & 1:
			for (k, v) in enumerate(c[j]):
				temp[k] += v
	if min(temp[1:]) >= x:
		ans = min(temp[0], ans)
print(ans if ans != 10 ** 7 else -1)


(n, m, x) = map(int, input().split())
Book = [[int(x) for x in input().split()] for j in range(n)]
Cost = 10 ** 7
for i in range(2 ** n):
	bag = [0 for k in range(n + 1)]
	for j in range(n):
		if i >> j & 1:
			bag = [x + y for (x, y) in zip(bag, Book[j])]
	if all((b >= x for b in bag[1:])):
		if Cost >= bag[0]:
			Cost = bag[0]
if Cost != 10 ** 7:
	print(Cost)
else:
	print(-1)


import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
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()


(n, m, y) = map(int, input().split())
List = [list(map(int, input().split())) for i in range(n)]
ans = 10000000000
for i in range(2 ** n):
	money = 0
	l = [0] * m
	for j in range(n):
		if i >> j & 1:
			money += List[j][0]
			for x in range(m):
				l[x] += List[j][x + 1]
	if all((c >= y for c in l)):
		if ans > money:
			ans = money
if ans == 10000000000:
	print(-1)
else:
	print(ans)


(n, m, x) = map(int, input().split())
ca = [list(map(int, input().split())) for _ in range(n)]
INF = float('inf')
ans = INF
for i in range(2 ** n):
	tmp = 0
	tmp_l = [0] * m
	for j in range(n):
		if i & 1 << j:
			tmp += ca[j][0]
			for k in range(m):
				tmp_l[k] += ca[j][1 + k]
	if min(tmp_l) >= x:
		ans = min(ans, tmp)
if ans == INF:
	ans = -1
print(ans)


(N, M, X) = list(map(int, input().split()))
C = []
A = []
for n in range(N):
	AC = list(map(int, input().split()))
	C.append(AC[0])
	A.append(AC[1:])
ans = 10 ** 9
for n in range(2 ** N):
	total = 0
	und = [0] * M
	for j in range(N):
		if n >> j & 1:
			total += C[j]
			for m in range(M):
				und[m] += A[j][m]
	if X <= min(und):
		ans = min(total, ans)
if ans == 10 ** 9:
	print(-1)
else:
	print(ans)


(N, M, X) = map(int, input().split())
alist = [list(map(int, input().split())) for _ in range(N)]
ans = float('inf')
for i in range(2 ** N):
	current = [0] * (M + 1)
	for j in range(N):
		if i >> j & 1:
			for k in range(M + 1):
				current[k] += alist[j][k]
	if X <= min(current[1:]) and current[0] < ans:
		ans = current[0]
print(-1 if ans == float('inf') else ans)


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) = [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):
	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))