#include <bits/stdc++.h>
using namespace std;
int n, m, k, ans[102];
int a[105][105], cnt[105][105];
bool locked[105];
int main() {
  int i, j, t;
  scanf("%d%d%d", &n, &m, &k);
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) scanf("%d", &a[i][j]);
  memset(ans, 0, sizeof(ans));
  memset(locked, 0, sizeof(locked));
  for (j = 1; j <= m; j++) {
    memset(cnt, 0, sizeof(cnt));
    for (i = 1; i <= n; i++)
      if (ans[i] == 0) {
        cnt[a[i][j]][0]++;
        cnt[a[i][j]][cnt[a[i][j]][0]] = i;
      }
    for (i = 1; i <= n; i++)
      if (locked[a[i][j]]) {
        if (ans[i] == 0) ans[i] = j;
      }
    for (i = 1; i <= k; i++)
      if (cnt[i][0] >= 2) {
        for (t = 1; t <= cnt[i][0]; t++)
          if (ans[cnt[i][t]] == 0) {
            ans[cnt[i][t]] = j;
          }
        locked[i] = true;
      }
  }
  for (i = 1; i <= n; i++) printf("%d\n", ans[i]);
  return 0;
}
