#include <bits/stdc++.h>
using namespace std;
const int INF = (int)1e9 + 7;
const int MXN = (int)3e2 + 7;
int n, m, k;
int job[MXN][MXN];
int cell[MXN], core[MXN];
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      scanf("%d", &job[i][j]);
    }
  }
  for (int i = 1; i <= m; i++) {
    int u[MXN];
    memset(u, 0, sizeof(u));
    for (int j = 1; j <= n; j++) {
      if (core[j]) continue;
      if (!job[j][i]) continue;
      if (cell[job[j][i]]) core[j] = i;
    }
    for (int j = 1; j <= n; j++) {
      if (core[j]) continue;
      if (!job[j][i]) continue;
      u[job[j][i]]++;
      if (u[job[j][i]] > 1) cell[job[j][i]] = 1;
    }
    for (int j = 1; j <= n; j++) {
      if (core[j]) continue;
      if (!job[j][i]) continue;
      if (cell[job[j][i]]) core[j] = i;
    }
  }
  for (int i = 1; i <= n; i++) printf("%d\n", core[i]);
  return 0;
}
