#include using namespace std; int dp[11][501]; int main() { int n, m, k; cin >> n >> m >> k; for (int i = 0; i < n; ++i) { for (int j = 0; j < 501; ++j) { dp[i][j] = -1; } } dp[0][0] = 0; for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { int a; cin >> a; for (int s = 0; s <= k; ++s) { if (dp[i][s] >= 0) { dp[i+1][s+a] = dp[i][s]+a; } } } } int ans = -1; for (int i = 0; i <= k; ++i) { ans = max(ans, dp[n][i]); } if (ans == 0) { cout << -1 << endl; } else { cout << k-ans << endl; } }