#include #define rep(i,n) for(int i=0;i P; const int INF = 1e9; const int MOD = 1000000007; int main(){ int n,m,k; cin >> n >> m >> k; vector> a(n,vector(m,0)); rep(i,n)rep(j,m) cin >> a[i][j]; vector> dp(n+1,vector(k+1,0)); dp[0][0] = 1; for(int i=1;i<=n;i++){ rep(j,k+1){ for(int p:a[i-1]){ if( j - p >= 0){ dp[i][j] += dp[i-1][j-p]; } } } } for(int i=k;i>=0;i--){ if(dp[n][i] > 0){ cout << k-i << endl; return 0; } } cout << -1 << endl; }