#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  int n, m, k;
  int core[101];
  bool memory[101];
  int x[101][101];
  scanf("%d %d %d", &n, &m, &k);
  for (int i = 0; i < 101; ++i) {
    memory[i] = true;
    core[i] = 0;
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      scanf("%d", &x[i][j]);
    }
  }
  for (int j = 1; j <= m; ++j) {
    vector<pair<int, int> > v;
    for (int i = 1; i <= n; ++i) {
      if (core[i] == 0) {
        if (x[i][j] == 0) {
          continue;
        } else if (!memory[x[i][j]]) {
          core[i] = j;
          continue;
        }
        for (int p = 0; p < v.size(); ++p) {
          if (v[p].first == x[i][j]) {
            memory[x[i][j]] = false;
            ;
            core[i] = j;
            core[v[p].second] = j;
          }
        }
        v.push_back(pair<int, int>(x[i][j], i));
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    printf("%d\n", core[i]);
  }
  return 0;
}
