#include <bits/stdc++.h>
using namespace std;
const double Pi = acos(-1.0);
const int maxn = 105;
int lTime[maxn], ins[maxn][maxn];
bool lockedCore[maxn], lockedCell[maxn];
int n, m, k;
int main() {
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> ins[i][j];
      ins[i][j]--;
    }
  }
  for (int time = 0; time < m; time++) {
    vector<int> instruct[maxn];
    for (int i = 0; i < n; i++) {
      int writeTo = ins[i][time];
      if (writeTo == -1 || lockedCore[i]) {
        continue;
      }
      if (lockedCell[writeTo]) {
        lockedCore[i] = true;
        lTime[i] = time + 1;
      } else {
        instruct[writeTo].push_back(i);
      }
    }
    for (int i = 0; i < k; i++) {
      if (instruct[i].size() > 1) {
        lockedCell[i] = true;
        for (int j = 0; j < instruct[i].size(); j++) {
          lockedCore[instruct[i][j]] = true;
          lTime[instruct[i][j]] = time + 1;
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    cout << lTime[i] << '\n';
  }
  return 0;
}
