#include #define rep(i,n) for(int i=(0);i<(n);i++) using namespace std; typedef long long ll; template bool chmax(T &a, const T &b) { if (a bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; } int main(){ cin.tie(0); ios::sync_with_stdio(false); int n, m, k; cin >> n >> m >> k; int a[n][m]; rep(i, n) rep(j, m) cin >> a[i][j]; bool dp[n+1][k+1]; rep(i, n+1) rep(j, k+1) dp[i][j] = false;; dp[0][k] = true; rep(i, n) rep(j, k+1) rep(l, m){ if(j + a[i][l] <= k) dp[i+1][j] = dp[i+1][j] | dp[i][j+a[i][l]]; } rep(i, k+1){ if(dp[n][i]){ cout << i << endl; return 0; } } cout << -1 << endl; }