#include <bits/stdc++.h>
using namespace std;
int n, m, k, t;
int nn[200];
int kk[200];
int bf[200];
int d[200][200];
int main() {
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++)
    for (int o = 1; o <= m; o++) cin >> d[i][o];
  for (int i = 1; i <= m; i++) {
    for (int o = 1; o <= n; o++) {
      t = d[o][i];
      if ((t == 0) || (nn[o] != 0)) continue;
      if (kk[t] == 1) {
        nn[o] = i;
        continue;
      }
      if (bf[t] != 0) {
        kk[t] = 1;
        nn[o] = i;
        nn[bf[t]] = i;
        continue;
      }
      bf[t] = o;
    }
    for (int o = 1; o <= k; o++) bf[o] = 0;
  }
  for (int i = 1; i <= n; i++) cout << nn[i] << endl;
  return 0;
}
