#include <bits/stdc++.h>
using namespace std;
int num[105][105];
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) cin >> num[i][j];
  }
  int ans[105] = {0}, vis[105], occupied[105] = {0};
  for (int i = 1; i <= m; i++) {
    memset(vis, 0, sizeof(vis));
    for (int j = 1; j <= n; j++) {
      if (ans[j] || num[j][i] == 0) continue;
      if (occupied[num[j][i]]) {
        ans[j] = i;
        continue;
      }
      if (vis[num[j][i]]) {
        ans[vis[num[j][i]]] = ans[j] = i;
        occupied[num[j][i]] = 1;
      } else
        vis[num[j][i]] = j;
    }
  }
  for (int i = 1; i <= n; i++) cout << ans[i] << endl;
  return 0;
}
