#include using i64 = long long; int main() { int n, m, k; std::cin >> n >> m >> k; std::vector> a(n, std::vector(m)); for (auto &v : a) for (auto &e : v) std::cin >> e; std::vector dp(501); dp[0] = 1; for (int i = 0; i < n; i++) { std::vector next(501); for (int j = 0; j < m; j++) { for (int l = 0; l + a[i][j] <= 500; l++) { if (dp[l]) next[l + a[i][j]] = 1; } } std::swap(dp, next); } int max = -1; for (int i = 0; i <= k; i++) if (dp[i]) max = k - i; std::cout << max << std::endl; return 0; }