#include <bits/stdc++.h>
using namespace std;
long n, m, k, ttl[200000], ar[200][200], bad[200];
long er[2000];
int main() {
  ios_base::sync_with_stdio(0);
  for (int i = 1; i <= 1000; i++) er[i] = 1e9;
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) cin >> ar[j][i];
  for (long i = 1; i <= m; i++) {
    for (int j = 1; j <= k; j++) ttl[j] = 0;
    for (int j = 1; j <= n; j++) {
      if (er[j] > 1e7) ttl[ar[i][j]]++;
    }
    for (int j = 1; j <= k; j++)
      if (ttl[j] > 1) bad[j] = 1;
    for (long j = 1; j <= n; j++) {
      if (bad[ar[i][j]]) er[j] = min(er[j], i);
    }
  }
  for (int i = 1; i <= n; i++)
    if (er[i] > 1e6) er[i] = 0;
  for (int i = 1; i <= n; i++) cout << er[i] << endl;
  cin.get();
  cin.get();
  return 0;
}
