N, M, K = map(int, input().split()) A = [list(map(int, input().split())) for _ in range(N)] dp = [False] * (K+1) dp[0] = True for i in range(N): nx = [False] * (K+1) for a in A[i]: for j in range(K+1): if j + a > K: break nx[j+a] |= dp[j] dp = nx for i in range(K+1)[::-1]: if dp[i]: print(K-i) exit() print(-1)