#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  int a[100][100];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> a[i][j];
  int cnt[101];
  int cores[100];
  bool cells[101];
  memset(cores, 0, sizeof(cores));
  memset(cells, 1, sizeof(cells));
  for (int i = 0; i < m; i++) {
    memset(cnt, 0, sizeof(cnt));
    for (int j = 0; j < n; j++) {
      if (a[j][i] && cores[j] == 0 && cells[a[j][i]]) cnt[a[j][i]]++;
    }
    for (int j = 0; j < n; j++) {
      if ((cores[j] == 0) && (cnt[a[j][i]] > 1 || !cells[a[j][i]])) {
        cores[j] = i + 1;
        cells[a[j][i]] = 0;
      }
    }
  }
  for (int i = 0; i < n; i++) cout << cores[i] << "\n";
  return 0;
}
