#include using namespace std; typedef long long ll; #define REP(i,n) for(int i=0; i #define VLL vector #define VVI vector> #define VVLL vector> #define VC vector #define VS vector #define VVC vector> #define VB vector #define VVB vector> #define fore(i,a) for(auto &i:a) typedef pair P; template bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } const int INF = 1 << 29; const ll INFL = 1LL << 60; const ll mod = 1000000007; int main() { int n, m, k; cin >> n >> m >> k; VVI v(n, VI(m)); REP(i, n)REP(j, m)cin >> v[i][j]; int sum = 0; REP(i, n) { int a = INF; REP(j, m)a = min(a, v[i][j]); sum += a; } if (sum > k) { cout << -1 << endl; return 0; } VB a(k + 1, false); VB b(k + 1, false); a[k] = true; b[k] = true; REP(i, n) { REP(j, m) { REP(l, k) { if (l + v[i][j] > k)continue; if (a[l + v[i][j]])b[l] = true; } } a = b; REP(j, k+1)b[j] = false; } REP(i, k) { if (a[i]) { cout << i << endl; return 0; } } }