#include using namespace std; #define REP(i,a,n) for(int i=(a); i<(int)(n); i++) #define rep(i,n) REP(i,0,n) #define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it) #define ALLOF(c) (c).begin(), (c).end() typedef long long ll; typedef unsigned long long ull; int main(){ int N, M, K; cin >> N >> M >> K; bitset<501> b; b[0] = true; rep(i,N){ bitset<501> t; rep(j,M){ int a; cin >> a; t |= b << a; } b = t; } int ret = -1; rep(i,K+1){ if(b[i]) ret = i; } if(ret == -1) cout << -1 << endl; else cout << K-ret << endl; return 0; }