#include <bits/stdc++.h>
using namespace std;
struct P {
  int core;
  int cell;
};
int cmp(const P &a, const P &b) {
  if (a.cell != b.cell) {
    return a.cell < b.cell;
  } else {
    return a.core < b.core;
  }
}
P p[100 + 8];
int main() {
  int n, m, k;
  int a[100 + 5][100 + 5];
  scanf("%d %d %d", &n, &m, &k);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) scanf("%d", &a[i][j]);
  int cellcon[100 + 9];
  int corecon[100 + 9];
  memset(corecon, 0, sizeof(corecon));
  memset(cellcon, 0, sizeof(cellcon));
  p[0].cell = 0;
  p[0].core = 0;
  for (int j = 1; j <= m; j++) {
    for (int i = 1; i <= n; i++) {
      p[i].core = i;
      p[i].cell = a[i][j];
    }
    sort(p, p + n + 1, cmp);
    int visit = 0;
    for (int i = 1; i <= n; i++) {
      if (p[i].cell == 0) continue;
      if (p[i].cell == p[i + 1].cell) {
        corecon[p[i].core] = j;
        corecon[p[i + 1].core] = j;
        for (int c = j + 1; c <= m; c++) {
          a[p[i].core][c] = 0;
          a[p[i + 1].core][c] = 0;
        }
        cellcon[p[i].cell]++;
      } else if (cellcon[p[i].cell] >= 1) {
        corecon[p[i].core] = j;
        for (int c = j + 1; c <= m; c++) {
          a[p[i].core][c] = 0;
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) printf("%d\n", corecon[i]);
  return 0;
}
