import numpy as np

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

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

a=[np.array(i[1:]) for i in ca]

c=[i[0] for i in ca]

xx=np.array([x]*m)

ans=pow(10,9)



for i in range(2**n):

  count=0

  aa=np.array([0]*m)

  for j in range(n):

    if ((i >> j) & 1):

      aa+=a[j]

      count+=c[j]  

    if all(i>=x for i in aa):

      ans=min(ans,count)

print((ans if ans<pow(10,9) else -1))
from itertools import product

import numpy as np

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

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

a,c=np.array([i[1:] for i in ca]).T,np.array([i[0] for i in ca])

ans=pow(10,9)

for i in product([0,1],repeat=n):

  i=np.array(i)

  if all(np.dot(a,i)>=x):

    s=np.dot(i,c)

    ans=s if s<ans else ans

print((ans if ans<pow(10,9) else -1))
import numpy as np

n, m, x = list(map(int, input().split()))
ca = [list(map(int, input().split())) for _ in range(n)]
a = [np.array(i[1:]) for i in ca]
c = [i[0] for i in ca]
xx = np.array([x] * m)
ans = pow(10, 9)
for i in range(2**n):
    count = 0
    aa = np.array([0] * m)
    for j in range(n):
        if (i >> j) & 1:
            aa += a[j]
            count += c[j]
        if all(i >= x for i in aa):
            ans = min(ans, count)
print((ans if ans < pow(10, 9) else -1))

from itertools import product
import numpy as np

n, m, x = list(map(int, input().split()))
ca = [list(map(int, input().split())) for _ in range(n)]
a, c = np.array([i[1:] for i in ca]).T, np.array([i[0] for i in ca])
ans = pow(10, 9)
for i in product([0, 1], repeat=n):
    i = np.array(i)
    if all(np.dot(a, i) >= x):
        s = np.dot(i, c)
        ans = s if s < ans else ans
print((ans if ans < pow(10, 9) else -1))

+from itertools import product -a = [np.array(i[1:]) for i in ca] -c = [i[0] for i in ca] -xx = np.array([x] * m) +a, c = np.array([i[1:] for i in ca]).T, np.array([i[0] for i in ca]) -for i in range(2**n): -    count = 0 -    aa = np.array([0] * m) -    for j in range(n): -        if (i >> j) & 1: -            aa += a[j] -            count += c[j] -        if all(i >= x for i in aa): -            ans = min(ans, count) +for i in product([0, 1], repeat=n): +    i = np.array(i) +    if all(np.dot(a, i) >= x): +        s = np.dot(i, c) +        ans = s if s < ans else ans