#include using namespace std; using ll = long long; using Pll = pair; using Pii = pair; constexpr ll MOD = 1000000007; constexpr int INF = 1 << 30; constexpr long double EPS = 1e-10; constexpr int dyx[4][2] = { { 0, 1}, {-1, 0}, {0,-1}, {1, 0} }; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n, m, k; cin >> n >> m >> k; vector> a(n, vector(m)); for(int i=0;i> a[i][j]; } vector> dp(n+1, vector(k+1, false)); dp[0][k] = true; for(int i=0;i=0;--j) { if(dp[n][j]) ans = j; } cout << ((ans==INF)?-1:ans) << endl; }