#include <bits/stdc++.h>
int ni() {
  int k1;
  scanf("%d", &k1);
  return k1;
}
int cmd[100 + 10][100 + 10];
int stk[100 + 10][100 + 10];
int nstk[100 + 10];
bool dead[100 + 10];
int locked[100 + 10];
int n, m, k;
int main() {
  n = ni();
  m = ni();
  k = ni();
  for (int(i) = 0; (i) < (n); (i)++)
    for (int(j) = 0; (j) < (m); (j)++) cmd[i][j] = ni();
  memset(dead, 0, sizeof(dead));
  memset(locked, 0, sizeof(locked));
  for (int(qq) = 0; (qq) < (m); (qq)++) {
    for (int(i) = 0; (i) < (k); (i)++) nstk[i] = 0;
    for (int(i) = 0; (i) < (n); (i)++) {
      if (locked[i] == 0) {
        int cmem = cmd[i][qq];
        if (cmem == 0) continue;
        cmem--;
        if (dead[cmem]) {
          locked[i] = qq + 1;
        } else {
          stk[cmem][nstk[cmem]++] = i;
        }
      }
    }
    for (int(i) = 0; (i) < (k); (i)++) {
      if (!dead[i])
        if (nstk[i] > 1) {
          for (int(j) = 0; (j) < (nstk[i]); (j)++) {
            locked[stk[i][j]] = qq + 1;
          }
          dead[i] = true;
        }
    }
  }
  for (int(i) = 0; (i) < (n); (i)++) printf("%d\n", locked[i]);
  return 0;
}
