#include using namespace std; #define FOR(i, m, n) for(int (i) = (m); (i) < (n); (i)++) #define rep(i, n) FOR(i, 0, n) #define co(n) cout << (n) << endl #define cosp(n) cout << (n) << ' ' #define all(s) (s).begin(), (s).end() #define pb push_back #define mp make_pair #define fs first #define sc second typedef long long ll; typedef pair P; const ll INF = 1e9+1; const ll LINF = 1e18+1; const ll MOD = 1e9+7; //const ll MOD = 998244353; bool dp[10][501] = {}; int main(void){ int n, m, k; cin >> n >> m >> k; vector > a(n, vector(m)); rep(i, n){ rep(j, m) cin >> a[i][j]; } rep(i, m){ if(a[0][i] <= k){ dp[0][a[0][i]] = true; } } FOR(i, 1, n){ rep(j, m){ rep(h, k-a[i][j]+1){ if(dp[i-1][h]){ dp[i][h+a[i][j]] = true; } } } } /* rep(i, n){ rep(j, k) cosp(dp[i][j]); cout << endl; } */ for(int i = k; i > 0; i--){ if(dp[n-1][i]){ co(k-i); return 0; } } co(-1); return 0; }