#include using namespace std; using ll = long long; constexpr ll inf = (1LL << 62); template bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; } template bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; } ll dp[20][510]; int main() { ll n, m, k; cin >> n >> m >> k; vector> a(n, vector(m)); for (ll i = 0; i < n; ++i) { for (ll j = 0; j < m; ++j) { cin >> a[i][j]; } } dp[0][0] = 1; for (ll i = 0; i < n; ++i) { for (ll j = 0; j <= k; ++j) { //dp[i + 1][j] = dp[i][j]; for (ll l = 0; l < m; ++l) { if (j >= a[i][l]) { dp[i + 1][j] |= dp[i][j - a[i][l]]; } } } } for (ll i = k; i >= 0; i--) { if (dp[n][i] != 0) { cout << k - i << endl; return 0; } } cout << -1 << endl; }