#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7, N = 1e3 + 7;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, m, k;
  cin >> n >> m >> k;
  vector<vector<long long>> v(n, vector<long long>(m));
  vector<long long> ans(n, -1), cell(100, 0);
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      cin >> v[i][j];
      v[i][j]--;
    }
  }
  for (long long j = 0; j < m; j++) {
    vector<long long> e(k, -1);
    for (long long i = 0; i < n; i++) {
      long long curr = v[i][j];
      if (curr == -1)
        continue;
      else if (ans[i] != -1)
        continue;
      else if (cell[curr] == 1) {
        ans[i] = j;
      } else if (e[curr] == -1) {
        e[curr] = i;
      } else {
        cell[curr] = 1;
        ans[i] = ans[e[curr]] = j;
      }
    }
  }
  for (auto i : ans) cout << i + 1 << endl;
}
