#include <bits/stdc++.h>
using namespace std;
ifstream fin("B.in");
const int MAXN = 105;
int N, M, K;
int mat[MAXN][MAXN], coreBlocked[MAXN];
bool cellBlocked[MAXN];
vector<int> block[MAXN];
int main() {
  cin >> N >> M >> K;
  for (int i = 1; i <= N; ++i)
    for (int j = 1; j <= M; ++j) cin >> mat[i][j];
  for (int cycle = 1; cycle <= M; ++cycle) {
    for (int core = 1; core <= N; ++core) {
      if (coreBlocked[core]) continue;
      if (cellBlocked[mat[core][cycle]])
        coreBlocked[core] = cycle;
      else
        block[mat[core][cycle]].push_back(core);
    }
    for (int cell = 1; cell <= K; ++cell) {
      if (block[cell].size() > 1) {
        cellBlocked[cell] = true;
        for (size_t i = 0; i < block[cell].size(); ++i)
          coreBlocked[block[cell][i]] = cycle;
      }
      block[cell].clear();
    }
  }
  for (int i = 1; i <= N; ++i) cout << coreBlocked[i] << '\n';
  fin.close();
  return 0;
}
