#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
int n, m, k;
int a[107][107];
int cnt[107];
bool f[107];
int b[107];
int main() {
  srand(time(NULL));
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> a[i][j];
  for (int i = 0; i < m; i++) {
    memset(cnt, 0, sizeof(cnt));
    for (int j = 0; j < n; j++)
      if (!b[j] && f[a[j][i]]) b[j] = i + 1;
    for (int j = 0; j < n; j++)
      if (!b[j] && a[j][i]) cnt[a[j][i]]++;
    for (int j = 0; j < n; j++)
      if (!b[j] && cnt[a[j][i]] > 1) b[j] = i + 1, f[a[j][i]] = true;
  }
  for (int i = 0; i < n; i++) cout << b[i] << endl;
  return 0;
}
