#include #include using namespace std; int main(){ 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][K] = true; for (int i = 0; i < N; i++){ for (int j = 0; j <= K; j++){ if (dp[i][j]){ for (int k = 0; k < M; k++){ if (j >= A[i][k]){ dp[i + 1][j - A[i][k]] = true; } } } } } for (int i = 0; i <= K; i++){ if (dp[N][i]){ cout << i << endl; return 0; } } cout << -1 << endl; }