救救孩子qwq
#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<stack>
#include<set>
#define NDEBUG
#include <assert.h>
using namespace std;
typedef long long ll;
#define debug(x)std::cout << "Line" << __LINE__ << " " << #x << "=" << x << std::endl
#define inf 0x3f3f3f3f
#define MAXN 100005
#define maxn 1005
int t, n, m, ans, p[maxn][maxn], f[MAXN];
int main() {
cin >> t >> n >> m;
for(int i = 1; i <= t; ++i) {
for(int j = 1; j <= n; ++j) {
scanf("%d", &p[i][j]);
}
}
for(int i = 1; i <= t; ++i) {
memset(f, 0, sizeof(f));
for(int j = 1; j <= n; ++j) {
for(int k = p[i][j]; k <= m; ++k) {
f[k] = max(f[k], f[k-p[i][j]]+p[i+1][j]-p[i][j]);
}
if(f[m] > 0) m += f[m];
}
}
cout << m;
return 0;
}