#include <bits/stdc++.h>
using namespace std;
const int N = 100;
int main() {
  int i, j, n, m, k;
  int num[N + 2][N + 2], cnt[N + 2] = {0}, cyc[N + 2];
  vector<int> flag[N + 2];
  bool lock[N + 2] = {false}, mem[N + 2] = {false};
  cin >> n >> m >> k;
  for (i = 0; i < n; ++i)
    for (j = 0; j < m; ++j) cin >> num[i][j];
  for (i = 0; i < m; ++i) {
    memset(cnt, 0, sizeof(cnt));
    for (j = 0; j < n; ++j) {
      int t = num[j][i];
      if (mem[t]) ++cnt[t];
      if (!lock[j + 1]) ++cnt[t];
      flag[t].push_back(j + 1);
    }
    for (int i1 = 1; i1 <= k; ++i1) {
      if (cnt[i1] > 1) {
        mem[i1] = true;
        int len = flag[i1].size();
        for (j = 0; j < len; ++j) {
          if (!lock[flag[i1][j]]) {
            lock[flag[i1][j]] = true;
            cyc[flag[i1][j]] = i + 1;
          }
        }
      }
    }
    for (j = 1; j <= k; ++j) flag[j].clear();
  }
  for (i = 1; i <= n; ++i)
    if (lock[i])
      cout << cyc[i] << endl;
    else
      cout << '0' << endl;
  return 0;
}
