#include using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define req(i,n) for(int i = 1;i <= n; i++) #define rrep(i,n) for(ll i = n-1;i >= 0;i--) #define ALL(obj) begin(obj), end(obj) #define RALL(a) rbegin(a),rend(a) typedef long long int ll; typedef long double ld; const int MAX = 510000; const ll MOD = 1000000007; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } const ll INF = 1e18; int main(){ int n,m,k;cin >>n>>m>>k; vector> a(n,vector(m)); rep(i,n) rep(j,m) cin >>a[i][j]; vector> dp(n+1,vector(600,0)); dp[0][k] = 1; rep(i,n){ rep(j,k+1){ if(dp[i][j]==0)continue; rep(l,m){ if(j 0) chmin(ans,i); }if(ans==1e9) cout << -1 << endl; else cout << ans <