N,M,K = map(int, input().split()) A = [[int(a) for a in input().split()] for _ in range(N)] dp = [[False]*(K+1) for _ in range(2)] dp[0][0] = True num = 0 ans = 0 for i in range(N): num = (num+1)%2 dp[num] = [False]*(K+1) cnt = 0 for j in range(M): for k in range(K+1): if k+A[i][j] > K: continue if dp[(num+1)%2][k]: dp[num][k+A[i][j]] = True cnt += 1 if cnt == 0: ans = -1 if ans == 0: for k in range(K, -1, -1): if dp[num][k]: ans = K-k break print(ans)