#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  int x[n][m];
  int lockedCore[n];
  bool lockedMem[k + 1];
  for (int ctr1 = 0; ctr1 <= k; ctr1++) {
    lockedMem[ctr1] = 0;
  }
  for (int ctr1 = 0; ctr1 < n; ctr1++) {
    lockedCore[ctr1] = 0;
  }
  for (int ctr1 = 0; ctr1 < n; ctr1++) {
    for (int ctr2 = 0; ctr2 < m; ctr2++) {
      cin >> x[ctr1][ctr2];
    }
  }
  for (int ctr1 = 0; ctr1 < m; ctr1++) {
    for (int ctr2 = 0; ctr2 < n; ctr2++) {
      if (x[ctr2][ctr1] != 0) {
        if (lockedCore[ctr2] == 0) {
          if (lockedMem[x[ctr2][ctr1]] == 1) {
            lockedCore[ctr2] = ctr1 + 1;
          } else
            for (int ctr3 = ctr2 + 1; ctr3 < n; ctr3++) {
              if (lockedCore[ctr3] == 0)
                if (x[ctr2][ctr1] == x[ctr3][ctr1]) {
                  lockedCore[ctr2] = ctr1 + 1;
                  lockedCore[ctr3] = ctr1 + 1;
                  lockedMem[x[ctr2][ctr1]] = 1;
                }
            }
        }
      }
    }
  }
  for (int ctr1 = 0; ctr1 < n; ctr1++) {
    cout << lockedCore[ctr1] << endl;
  }
  return 0;
}
