#include <bits/stdc++.h>
using namespace std;
struct thing {
  int s = 0;
  vector<int> p;
};
int main() {
  int n, m, k, i, t, x;
  cin >> n >> m >> k;
  thing memory[k], processor[n];
  int table[n][m];
  for (i = 0; i < n; i++) {
    for (t = 0; t < m; t++) cin >> table[i][t];
  }
  for (i = 0; i < m; i++) {
    for (t = 0; t < n; t++) {
      x = table[t][i];
      if (x == 0) continue;
      if (processor[t].s) continue;
      if (memory[x - 1].s == -1)
        processor[t].s = i + 1;
      else
        memory[x - 1].p.push_back(t);
    }
    for (t = 0; t < k; t++) {
      if (memory[t].p.size() > 1) {
        memory[t].s = -1;
        for (x = 0; x < memory[t].p.size(); x++) {
          processor[memory[t].p[x]].s = i + 1;
        }
      }
      memory[t].p.clear();
    }
  }
  for (i = 0; i < n; i++) cout << processor[i].s << endl;
  return 0;
}
