#include <bits/stdc++.h>
using namespace std;
int a[101][101];
int b_k[105];
int b_n[105];
int main() {
  int n, m, k;
  scanf("%d", &n);
  scanf("%d", &m);
  scanf("%d", &k);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      scanf("%d", &a[i][j]);
    }
  }
  for (int i = 1; i < k + 1; ++i) {
    b_k[i] = -1;
  }
  for (int i = 0; i < m; ++i) {
    for (int j = 0; j < n; ++j) {
      if (b_n[j] > 0) continue;
      if (a[j][i] == 0) continue;
      if (b_k[a[j][i]] > -1) {
        b_n[b_k[a[j][i]]] = i + 1;
        b_n[j] = i + 1;
        b_k[a[j][i]] = 1000;
      } else {
        b_k[a[j][i]] = j;
      }
    }
    for (int i = 1; i < k + 1; ++i) {
      if (b_k[i] != 1000) b_k[i] = -1;
    }
  }
  for (int j = 0; j < n; ++j) {
    printf("%d\n", b_n[j]);
  };
  return 0;
}
