#include using namespace std; int main() { ios::sync_with_stdio(false); 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> d(N + 1, vector(K + 1)); { d[0][K] = 1; for (int i = 0; i < N; ++i) { for (int j = 0; j <= K; ++j) { for (int a : A[i]) { if (j >= a) d[i + 1][j - a] |= d[i][j]; } } } } for (int i = 0; i <= K; ++i) if (d[N][i]) { cout << i << endl; return 0; } cout << -1 << endl; }