#include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N, M, K; cin >> N >> M >> K; vector> A(N, vector(M)); for (int i = 0; i < N; i++) { for (int j = 0; j < M; j++) { cin >> A[i][j]; } } vector> dp(N + 1, vector(K + 1, false)); dp[0][0] = true; for (int i = 0; i < N; i++) { for (int j = 0; j < M; j++) { for (int k = 0; k + A[i][j] < K + 1; k++) { dp[i + 1][k + A[i][j]] = dp[i + 1][k + A[i][j]] | dp[i][k]; } } } for (int i = K; i > -1; i--) { if (dp[N][i]) { cout << K - i << '\n'; return 0; } } cout << -1 << '\n'; return 0; }