#include <bits/stdc++.h>
using namespace std;
int n, m, i, j, k, l, r;
int a[101][101];
int b[101];
int isbreak[101];
int Isbreak[101];
int ans[101];
vector<int> now[101];
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (i = (1); i <= (n); i++)
    for (j = (1); j <= (m); j++) scanf("%d", &a[i][j]);
  for (i = (1); i <= (m); i++) {
    for (j = (1); j <= (n); j++) {
      if (Isbreak[j]) continue;
      if (isbreak[a[j][i]] && !ans[j]) ans[j] = i, Isbreak[j] = 1;
      b[a[j][i]]++;
      now[a[j][i]].push_back(j);
    }
    for (l = (1); l <= (k); l++) {
      if (!b[l] || b[l] <= 1) continue;
      isbreak[l] = 1;
      for (r = (0); r <= (now[l].size() - 1); r++)
        if (!ans[now[l][r]]) ans[now[l][r]] = i, Isbreak[now[l][r]] = 1;
    }
    for (l = (1); l <= (k); l++) now[l].clear();
    memset(b, 0, sizeof b);
  }
  for (i = (1); i <= (n); i++) printf("%d\n", ans[i]);
  return 0;
}
