#include <bits/stdc++.h>
using namespace std;
int const maxn = (int)1e3 + 111;
int const inf = (1 << 30) - 1;
int n, m, k;
int a[maxn][maxn];
bool isFailed[maxn];
int ans[maxn];
int main() {
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> a[i][j];
    }
  }
  for (int j = 1; j <= m; j++) {
    for (int i = 1; i <= n; i++) {
      if (ans[i] > 0) continue;
      if (a[i][j] == 0) continue;
      if (isFailed[a[i][j]]) {
        ans[i] = j;
        continue;
      }
      for (int k = 1; k <= n; k++) {
        if (i == k) continue;
        if (ans[k] > 0) continue;
        if (a[i][j] == a[k][j]) {
          ans[i] = j;
          isFailed[a[i][j]] = true;
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}
