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