#include //#define int long long using namespace std; using LL = long long; using P = pair; #define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i) #define REP(i, n) FOR(i, 0, n) #define pb(a) push_back(a) #define all(x) (x).begin(),(x).end() template vector make_v(size_t a){return vector(a);} template auto make_v(size_t a, Ts... ts) {return vector(ts...))>(a, make_v(ts...)); } template typename enable_if::value == 0>::type fill_v(T &t, const V &v){ t = v; } template typename enable_if::value != 0>::type fill_v(T &t, const V &v){ for(auto &e : t) fill_v(e, v); } const int INF = (int)1e9; const LL INFL = (LL)1e18; const int MOD = 1e9 + 7; signed main() { cin.tie(0); ios::sync_with_stdio(false); int n, m, k; cin >> n >> m >> k; auto a = make_v(n, m); REP(i, n) REP(j, m) cin >> a[i][j]; auto dp = make_v(n+1, 505); dp[0][k] = true; REP(i, n) REP(j, m) { REP(k, 501) { if(dp[i][k] && a[i][j] <= k) dp[i+1][k-a[i][j]] = true; } } REP(i, 501) if(dp[n][i]) { cout << i << endl; return 0; } cout << -1 << endl; }