n, m, k = map(int, input().split()) a = [list(map(int, input().split())) for i in range(n)] dp = [[False]*(k+1) for i in range(n+1)] dp[0][0] = True for i1 in range(n): for i2 in range(m): for j in range(k+1): if j-a[i1][i2] >= 0: dp[i1+1][j] = dp[i1+1][j] | dp[i1][j-a[i1][i2]] ans = -1 for i, j in enumerate(dp[-1]): if j: ans = k - i print(ans)