from bisect import bisect N,M,K = map(int,input().split()) A = [] for _ in range(N): a = list(map(int,input().split())) A.append(a) N //= 2 B = A[N:] A = A[:N] ans = 0 l,r = [],[] def perm(n,s,arr,h): global N if n == len(h): arr.append(s) return for a in h[n]: if s+a >= K: continue perm(n+1,s+a,arr,h) perm(0,0,l,A) perm(0,0,r,B) r.sort() if l == [] or r == []: print(-1) exit() for i in l: b = bisect(r,K-i) if i+r[b-1] > K: continue ans = max(ans,i+r[b-1]) if ans == 0: print(-1) else: print(K-ans)