import sys sys.setrecursionlimit(10**7) input = sys.stdin.readline def main(): N, M, K = map(int, input().split()) A = [list(map(int, input().split())) for _ in range(N)] dp = [0]*(K+1) dp[0] = 1 for i in range(N): tmp = [0]*(K+1) for j in range(M): k = 0 while k+A[i][j]<=K: if dp[k]: tmp[k+A[i][j]] = 1 k += 1 dp = tmp # print(dp) for i in reversed(range(K+1)): if dp[i]: print(K-i) return print(-1) if __name__ == '__main__': main()