#include <bits/stdc++.h>
int kar[105], arr[105][105], c[105];
int main() {
  int i, j, n, m, k, l, count, res;
  scanf("%d%d%d", &n, &m, &k);
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) scanf("%d", &arr[i][j]);
  }
  for (i = 0; i < m; i++) {
    for (l = 0; l <= k; l++) c[l] = 0;
    for (j = 0; j < n; j++) {
      if (i > 0 && arr[j][i - 1] == -1) {
        arr[j][i] = -1;
        continue;
      }
      if (arr[j][i] == 0) continue;
      if (kar[arr[j][i]] == -1) {
        arr[j][i] = -1;
        continue;
      }
      c[arr[j][i]]++;
      if (c[arr[j][i]] > 1) kar[arr[j][i]] = -1;
    }
    for (j = 0; j < n; j++) {
      if (kar[arr[j][i]] == -1) arr[j][i] = -1;
    }
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      if (arr[i][j] == -1) {
        printf("%d\n", j + 1);
        break;
      }
    }
    if (j == m) printf("0\n");
  }
  return 0;
}
