#include <bits/stdc++.h>
using namespace std;
void imp() {
  printf("Too weak");
  exit(0);
}
char st[100000];
int const MAX_N = 400;
int xx[500][500], mem_blocked[500], blocked[500], cur_cnt[500], ans[500];
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", &xx[i][j]);
  for (int j = 1; j <= m; j++) {
    for (int i = 0; i < MAX_N; i++) cur_cnt[i] = 0;
    for (int i = 1; i <= n; i++)
      if (!blocked[i] && xx[i][j] != 0) {
        if (mem_blocked[xx[i][j]]) {
          blocked[i] = 1;
          ans[i] = j;
        } else
          cur_cnt[xx[i][j]]++;
      }
    for (int i = 1; i <= n; i++)
      if (!blocked[i] && xx[i][j] != 0)
        if (cur_cnt[xx[i][j]] >= 2) {
          blocked[i] = 1;
          ans[i] = j;
          mem_blocked[xx[i][j]] = 1;
        }
  }
  for (int i = 1; i <= n; i++) cout << ans[i] << "\n";
  return 0;
}
