#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
bool b[200];
long long core[200];
long long x[200][200];
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long N, M, K;
  cin >> N >> M >> K;
  for (long long i = 0; i < N; i++) {
    for (long long j = 0; j < M; j++) {
      cin >> x[i][j];
    }
  }
  for (long long i = 0; i < M; i++) {
    vector<long long> d(200, -1);
    for (long long j = 0; j < N; j++) {
      long long a = x[j][i];
      if (a == 0 || core[j]) continue;
      if (b[a]) {
        core[j] = i + 1;
        continue;
      }
      if (d[a] != -1) {
        b[a] = 1;
        core[d[a]] = i + 1;
        core[j] = i + 1;
        continue;
      }
      d[a] = j;
    }
  }
  for (long long i = 0; i < N; i++) cout << core[i] << '\n';
}
