#include #include constexpr int K = 500; void solve() { int n, m, k; std::cin >> n >> m >> k; std::bitset dp{1}; auto ndp = dp; while (n--) { ndp = 0; for (int i = 0; i < m; ++i) { int a; std::cin >> a; ndp |= (dp << a); } std::swap(dp, ndp); } for (int i = k; i >= 0; --i) { if (dp[i]) { std::cout << k - i << std::endl; return; } } std::cout << -1 << std::endl; } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); solve(); return 0; }