#define _USE_MATH_DEFINES #include using namespace std; signed main() { ios::sync_with_stdio(false); cin.tie(0); int n, m, k; cin >> n >> m >> k; vector> dp(n + 1, vector(k + 1)); dp[0][0] = true; for (int i = 1; i <= n; i++) { for (int j = 0; j < m; j++) { int x; cin >> x; for (int u = 0; u <= k; u++) { if (u - x >= 0) if (dp[i - 1][u - x]) dp[i][u] = true; } } } for (int i = k; i > 1; i--) { if (dp[n][i]) { cout << k - i << '\n'; return 0; } } cout << -1 << '\n'; return 0; }