#include <bits/stdc++.h>
using namespace std;
int x[100][100];
int ans[200], bo[200];
struct da {
  int num, p;
} b[200];
bool cmp(da a, da b) { return a.num < b.num; }
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> x[i][j];
  memset(ans, 0, sizeof ans);
  memset(bo, 0, sizeof bo);
  for (int j = 0; j < m; j++) {
    int sum = 0;
    for (int i = 0; i < n; i++)
      if (ans[i] == 0 && x[i][j] > 0) {
        b[sum].num = x[i][j];
        b[sum].p = i;
        sum++;
      }
    sort(b, b + sum, cmp);
    for (int i = 0; i < sum; i++)
      if (((i > 0) && (b[i].num == b[i - 1].num)) ||
          ((i < sum - 1) && b[i].num == b[i + 1].num)) {
        ans[b[i].p] = j + 1;
        bo[b[i].num] = 1;
      }
    for (int i = 0; i < sum; i++)
      if (bo[b[i].num]) ans[b[i].p] = j + 1;
  }
  for (int i = 0; i < n; i++) cout << ans[i] << endl;
  return 0;
}
