#include <bits/stdc++.h>
using namespace std;
int in[150][150];
bool memlock[150];
bool tmplock[150];
bool prelock[150];
int precycle[150];
void solve(int n, int m) {
  memset(memlock, false, sizeof(memlock));
  memset(prelock, false, sizeof(prelock));
  memset(precycle, 0, sizeof(precycle));
  for (int j = 1; j <= m; j++) {
    memset(tmplock, false, sizeof(tmplock));
    for (int i = 1; i <= n; i++) {
      if (prelock[i]) continue;
      int mem = in[i][j];
      if (mem == 0) continue;
      if (memlock[mem]) {
        prelock[i] = true;
        precycle[i] = j;
        continue;
      }
      if (tmplock[mem])
        memlock[mem] = true;
      else
        tmplock[mem] = true;
    }
    for (int i = 1; i <= n; i++) {
      if (prelock[i]) continue;
      int mem = in[i][j];
      if (mem == 0) continue;
      if (memlock[mem]) {
        precycle[i] = j;
        prelock[i] = true;
      }
    }
  }
  for (int i = 1; i <= n; i++) cout << precycle[i] << endl;
}
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) cin >> in[i][j];
  solve(n, m);
}
