#include <bits/stdc++.h>
using namespace std;
const int MAX = 101;
int x[MAX][MAX];
bool locked[MAX];
int deadlock[MAX];
int main(int argc, char const *argv[]) {
  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 i = 1; i <= m; ++i) {
    int mem[MAX];
    memset(mem, 0, sizeof(mem));
    for (int j = 1; j <= n; ++j) {
      if (!deadlock[j] && x[j][i]) {
        if (locked[x[j][i]]) {
          deadlock[j] = i;
        } else {
          ++mem[x[j][i]];
        }
      }
    }
    for (int j = 1; j <= k; ++j) {
      if (mem[j] > 1) {
        locked[j] = true;
        for (int p = 1; p <= n; ++p) {
          if (!deadlock[p] && x[p][i] == j) {
            deadlock[p] = i;
          }
        }
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    printf("%d\n", deadlock[i]);
  }
  return 0;
}
