(n,m,x),*t=[[*list(map(int,t.split()))]for t in open(0)]

m=9**9

for i in range(1,2**n):

    c,*a=list(map(sum,list(zip(*[t[j]for j in range(n)if 1<<j&i]))))

    if min(a)>=x:m=min(m,c+1)

print((m%9**9-1))
(n,m,x),*t=[[*list(map(int,t.split()))]for t in open(0)]

m=M=9**9

for i in range(1,2**n):c,*a=list(map(sum,list(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), *t = [[*list(map(int, t.split()))] for t in open(0)]
m = 9**9
for i in range(1, 2**n):
    c, *a = list(map(sum, list(zip(*[t[j] for j in range(n) if 1 << j & i]))))
    if min(a) >= x:
        m = min(m, c + 1)
print((m % 9**9 - 1))

(n, m, x), *t = [[*list(map(int, t.split()))] for t in open(0)]
m = M = 9**9
for i in range(1, 2**n):
    c, *a = list(map(sum, list(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))

-m = 9**9 +m = M = 9**9 -    c, *a = list(map(sum, list(zip(*[t[j] for j in range(n) if 1 << j & i])))) -    if min(a) >= x: -        m = min(m, c + 1) -print((m % 9**9 - 1)) +    c, *a = list(map(sum, list(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))