// Src : Vux2Code
/* Note : 1
none
*/
#include <bits/stdc++.h>
using namespace std;
template <typename T> void vout(T s){ cout << s << endl; exit(0);}
typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pll;
const ll maxN = 20 + 5, maxLog = 20, inf64 = 1e18, mod = 1e9 + 7, maxW = 1e5 + 5;
ll t = 1;
ll n, m, w, b [maxN], a [maxN] [maxN], f [maxN] [maxN] [maxW];
void sortCol (ll x) {
for (int i = 1; i <= n; i ++) b [i] = a [i] [x];
sort (b + 1, b + n + 1);
for (int i = 1; i <= n; i ++) a [i] [x] = b [i];
}
void solve () {
cin >> n >> m >> w;
for (int i = 1; i <= n; i ++) {
for (int j = 1; j <= m; j ++) {
cin >> a [i] [j];
}
}
a [1] [0] = inf64;
f [0] [0] [0] = 1;
for (int j = 1, tmp; j <= m; j ++) {
sortCol (j);
tmp = 0;
for (int i = 1; i <= n; i ++) {
while (tmp < n && a [tmp + 1] [j - 1] < a [i] [j]) tmp ++;
// cerr << i << ' ' << j << ' ' << tmp << '\n';
for (int k = a [i] [j]; k <= w; k ++) f [i] [j] [k] = max (f [i] [j] [k], f [tmp] [j - 1] [k - a [i] [j]]);
for (int k = a [i] [j]; k <= w; k ++) f [i] [j] [k] = max (f [i] [j] [k], f [i - 1] [j] [k - a [i] [j] + a [i - 1] [j]]);
}
}
// cerr << "Sorted Board : \n";
// for (int i = 1; i <= n; i ++) {
// for (int j = 1; j <= m; j ++) {
// cerr << a [i] [j] << ' ';
// }
// cerr << '\n';
// }
// for (int i = 1; i <= n; i ++) {
// for (int j = 1; j <= m; j ++) {
// cerr << i << ' ' << j << " : " << a [i] [j] << " : ";
// for (int k = 0; k <= w; k ++) cerr << f [i] [j] [k] << ' ';
// cerr << '\n';
// }
// }
ll ans = -1;
for (int j = 1; j <= n; j ++) for (int i = 0; i <= w; i ++) if (f [j] [m] [i]) ans = i;
cout << ans;
}
int main () {
ios::sync_with_stdio (0);
cin. tie (0);
cout. tie (0);
// #define TASK "task"
// freopen (TASK".inp", "r", stdin);
// freopen (TASK".out", "w", stdout);
// cin >> t;
while (t --) solve ();
}
Ly8gU3JjIDogVnV4MkNvZGUKLyogTm90ZSA6IDEKICAgIG5vbmUKKi8KCiNpbmNsdWRlIDxiaXRzL3N0ZGMrKy5oPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCnRlbXBsYXRlIDx0eXBlbmFtZSBUPiB2b2lkIHZvdXQoVCBzKXsgY291dCA8PCBzIDw8IGVuZGw7IGV4aXQoMCk7fQoKdHlwZWRlZiBsb25nIGxvbmcgbGw7CnR5cGVkZWYgbG9uZyBkb3VibGUgbGQ7CnR5cGVkZWYgcGFpciA8bGwsIGxsPiBwbGw7Cgpjb25zdCBsbCBtYXhOID0gMjAgKyA1LCBtYXhMb2cgPSAyMCwgaW5mNjQgPSAxZTE4LCBtb2QgPSAxZTkgKyA3LCBtYXhXID0gMWU1ICsgNTsKCmxsIHQgPSAxOwoKbGwgbiwgbSwgdywgYiBbbWF4Tl0sIGEgW21heE5dIFttYXhOXSwgZiBbbWF4Tl0gW21heE5dIFttYXhXXTsKCnZvaWQgc29ydENvbCAobGwgeCkgewogICAgZm9yIChpbnQgaSA9IDE7IGkgPD0gbjsgaSArKykgYiBbaV0gPSBhIFtpXSBbeF07CiAgICBzb3J0IChiICsgMSwgYiArIG4gKyAxKTsKICAgIGZvciAoaW50IGkgPSAxOyBpIDw9IG47IGkgKyspIGEgW2ldIFt4XSA9IGIgW2ldOwp9Cgp2b2lkIHNvbHZlICgpIHsKICAgIGNpbiA+PiBuID4+IG0gPj4gdzsKICAgIGZvciAoaW50IGkgPSAxOyBpIDw9IG47IGkgKyspIHsKICAgICAgICBmb3IgKGludCBqID0gMTsgaiA8PSBtOyBqICsrKSB7CiAgICAgICAgICAgIGNpbiA+PiBhIFtpXSBbal07CiAgICAgICAgfQogICAgfQogICAgYSBbMV0gWzBdID0gaW5mNjQ7CiAgICBmIFswXSBbMF0gWzBdID0gMTsKICAgIGZvciAoaW50IGogPSAxLCB0bXA7IGogPD0gbTsgaiArKykgewogICAgICAgIHNvcnRDb2wgKGopOwogICAgICAgIHRtcCA9IDA7CiAgICAgICAgZm9yIChpbnQgaSA9IDE7IGkgPD0gbjsgaSArKykgewogICAgICAgICAgICB3aGlsZSAodG1wIDwgbiAmJiBhIFt0bXAgKyAxXSBbaiAtIDFdIDwgYSBbaV0gW2pdKSB0bXAgKys7IAogICAgICAgICAgICAvLyBjZXJyIDw8IGkgPDwgJyAnIDw8IGogIDw8ICcgJyA8PCB0bXAgPDwgJ1xuJzsKICAgICAgICAgICAgZm9yIChpbnQgayA9IGEgW2ldIFtqXTsgayA8PSB3OyBrICsrKSBmIFtpXSBbal0gW2tdID0gbWF4IChmIFtpXSBbal0gW2tdLCBmIFt0bXBdIFtqIC0gMV0gW2sgLSBhIFtpXSBbal1dKTsKICAgICAgICAgICAgZm9yIChpbnQgayA9IGEgW2ldIFtqXTsgayA8PSB3OyBrICsrKSBmIFtpXSBbal0gW2tdID0gbWF4IChmIFtpXSBbal0gW2tdLCBmIFtpIC0gMV0gW2pdIFtrIC0gYSBbaV0gW2pdICsgYSBbaSAtIDFdIFtqXV0pOwogICAgICAgIH0KICAgIH0KICAgIC8vIGNlcnIgPDwgIlNvcnRlZCBCb2FyZCA6IFxuIjsKICAgIC8vIGZvciAoaW50IGkgPSAxOyBpIDw9IG47IGkgKyspIHsKICAgIC8vICAgICBmb3IgKGludCBqID0gMTsgaiA8PSBtOyBqICsrKSB7CiAgICAvLyAgICAgICAgIGNlcnIgPDwgYSBbaV0gW2pdIDw8ICcgJzsKICAgIC8vICAgICB9CiAgICAvLyAgICAgY2VyciA8PCAnXG4nOwogICAgLy8gfQogICAgLy8gZm9yIChpbnQgaSA9IDE7IGkgPD0gbjsgaSArKykgewogICAgLy8gICAgIGZvciAoaW50IGogPSAxOyBqIDw9IG07IGogKyspIHsKICAgIC8vICAgICAgICAgY2VyciA8PCBpIDw8ICcgJyA8PCBqIDw8ICIgOiAiIDw8IGEgW2ldIFtqXSA8PCAiIDogIjsKICAgIC8vICAgICAgICAgZm9yIChpbnQgayA9IDA7IGsgPD0gdzsgayArKykgY2VyciA8PCBmIFtpXSBbal0gW2tdIDw8ICcgJzsKICAgIC8vICAgICAgICAgY2VyciA8PCAnXG4nOwogICAgLy8gICAgIH0KICAgIC8vIH0KICAgIGxsIGFucyA9IC0xOwogICAgZm9yIChpbnQgaiA9IDE7IGogPD0gbjsgaiArKykgZm9yIChpbnQgaSA9IDA7IGkgPD0gdzsgaSArKykgaWYgKGYgW2pdIFttXSBbaV0pIGFucyA9IGk7CiAgICBjb3V0IDw8IGFuczsKfQoKaW50IG1haW4gKCkgewogICAgaW9zOjpzeW5jX3dpdGhfc3RkaW8gKDApOwogICAgY2luLiB0aWUgKDApOwogICAgY291dC4gdGllICgwKTsKICAgIC8vICNkZWZpbmUgVEFTSyAidGFzayIKICAgIC8vIGZyZW9wZW4gKFRBU0siLmlucCIsICJyIiwgc3RkaW4pOwogICAgLy8gZnJlb3BlbiAoVEFTSyIub3V0IiwgInciLCBzdGRvdXQpOwogICAgLy8gY2luID4+IHQ7CiAgICB3aGlsZSAodCAtLSkgc29sdmUgKCk7Cn0=