N,M,K=map(int,input().split()) L=[] for i in range(N): a=list(map(int,input().split())) L.append(a) D={} D[0]=1 #print(L[1]) for i in range(N): d={} for j in D.keys(): for k in L[i]: #print(j,k) if j+k not in d and j+k<=K: d[j+k]=1 D=d ans=K for i in D.keys(): if ans>(K-i): ans=K-i if ans==K: print(-1) else: print(ans)