#include <bits/stdc++.h>
using namespace std;
const int N = 128;
bool core[N];
bool cell[N];
int p[N];
int q[N];
int inp[N][N];
int main() {
  int i, j, n, m, k;
  scanf(" %d %d %d", &n, &m, &k);
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) scanf(" %d", &inp[i][j]);
  for (i = 1; i <= m; i++) {
    for (j = 0; j <= k; j++) q[j] = -1;
    int x;
    for (j = 1; j <= n; j++) {
      x = inp[j][i];
      if (x == 0 || core[j]) continue;
      if (cell[x]) {
        core[j] = true;
        continue;
      }
      if (q[x] != -1) {
        core[q[x]] = true;
        core[j] = true;
        cell[x] = true;
        continue;
      }
      if (q[x] == -1) {
        q[x] = j;
      }
    }
    for (j = 1; j <= n; j++)
      if (core[j] && p[j] == 0) p[j] = i;
  }
  for (j = 1; j <= n; j++) printf("%d\n", p[j]);
  return 0;
}
