#include using namespace std; typedef unsigned long long ull; typedef long long ll; typedef pair pii; typedef pair pll; typedef pair pdd; const ull mod = 1e9 + 7; #define REP(i,n) for(int i=0;i<(int)n;++i) //debug #define dump(x) cerr << #x << " = " << (x) << endl; #define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; template ostream& operator << (ostream& os, const pair v){ os << "(" << v.first << ", " << v.second << ")"; return os; } template ostream& operator << (ostream& os, const vector v){ for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os; } template ostream& operator << (ostream& os, const vector> v){ for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os; } ll A[12][12]; ll dp[12][510]; int main(){ cin.tie(0); ios::sync_with_stdio(false); ll N, M, K; cin >> N >> M >> K; REP(i, N){ REP(j, M){ cin >> A[i][j]; } } REP(i, N+1){ REP(j, 510){ dp[i][j] = 0; } } dp[0][0] = 1; REP(i, N){ REP(j, 510){ if(dp[i][j] == 0) continue; REP(k, M){ if(j+A[i][k]<510) dp[i+1][j+A[i][k]] = 1; } } } ll ma = -1; REP(i, K+1){ if(dp[N][i]) ma = max(ma, (ll)i); } cout << (ma==-1 ? ma : K-ma) << endl; return 0; }