#include using namespace std; using LL = long long; using ULL = unsigned long long; bool dp[11][551]; int A[11][11]; int main() { int N, M, K; cin >> N >> M >> K; for (int i = 1; i <= N; i++) { for (int j = 1; j <= M; j++) { cin >> A[i][j]; } } dp[0][0] = true; for (int i = 1; i <= N; i++) { for (int j = 0; j <= K; j++) { if (dp[i - 1][j]) { for (int k = 1; k <= M; k++) { dp[i][j + A[i][k]] = true; } } } } int ans = -1; for (int i = K; i >= 0; i--) { if (dp[N][i]) { ans = K - i; break; } } cout << ans << endl; }