#include <bits/stdc++.h>
using namespace std;
int mat[110][110];
int lockedM[110];
int lockedC[110];
int used[110];
int main() {
  int N, M, K;
  cin >> N >> M >> K;
  for (int i = 0; i < N; ++i)
    for (int j = 0; j < M; ++j) cin >> mat[i][j];
  for (int i = 0; i < M; ++i) {
    memset(used, -1, sizeof(used));
    for (int j = 0; j < N; ++j) {
      if (lockedC[j]) continue;
      int p = mat[j][i];
      if (p == 0) continue;
      if (lockedM[p])
        lockedC[j] = i + 1;
      else if (used[p] != -1) {
        lockedC[used[p]] = i + 1;
        lockedC[j] = i + 1;
        lockedM[p] = 1;
      }
      used[p] = j;
    }
  }
  for (int i = 0; i < N; ++i) cout << lockedC[i] << endl;
}
