#include <bits/stdc++.h>
using namespace std;
const int INT_INF = 1e9;
const long long LL_INF = 1e18;
const int MAXN = 300000 + 2;
int x[102][102];
int is_locked[102];
int lnum[102];
int cnt[102];
int main() {
  int n, m, k;
  scanf("%d %d %d", &n, &m, &k);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      scanf("%d", &x[i][j]);
    }
  }
  for (int j = 1; j <= m; j++) {
    memset(cnt, 0, sizeof(cnt));
    for (int i = 1; i <= n; i++) {
      if (!lnum[i] && x[i][j]) cnt[x[i][j]]++;
    }
    for (int i = 1; i <= k; i++) {
      is_locked[i] |= (cnt[i] > 1);
    }
    for (int i = 1; i <= n; i++) {
      if (is_locked[x[i][j]] && !lnum[i]) lnum[i] = j;
    }
  }
  for (int i = 1; i <= n; i++) printf("%d\n", lnum[i]);
  return 0;
}
