N,M,K = map(int,input().split()) A = [[]]*N for i in range(N): A[i] = [int(a) for a in input().split()] dp = [0]*(K+1) dp[0] = 1 for i in range(N): tmp = [0]*(K+1) for j in range(M): for k in range(K+1): if dp[k] == 1 and k + A[i][j] <= K: tmp[k+A[i][j]] = 1 dp = tmp ans = -1 for k in range(K+1): if dp[k] == 1: ans = K - k print(ans)