#include <bits/stdc++.h>

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m, K;
    cin >> n >> m >> K;
    vector< vector<int> > a(n, vector<int>(m));
    vector<int> dp(K + 1, false);
    dp[0] = true;
    for (int i = 0; i < n; i++) {
        vector<int> ndp(K + 1, false);
        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
            for (int k = a[i][j]; k <= K; k++) {
                ndp[k] |= dp[k - a[i][j]];
            }
        }
        dp = move(ndp);
    }
    for (int i = K; i >= 0; i--) {
        if (dp[i]) {
            cout << K - i << "\n";
            return 0;
        }
    }
    cout << -1 << "\n";
    return 0;
}