#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, k, i, j, cmd[105][105];
  bool lockcell[105], curcell[105];
  int pro[105], prelock[105];
  while (scanf("%d %d %d", &n, &m, &k) == 3) {
    memset(lockcell, 0, sizeof(lockcell));
    memset(pro, 0, sizeof(pro));
    for (i = 0; i < n; i++) {
      for (j = 0; j < m; j++) {
        scanf("%d", &cmd[i][j]);
      }
    }
    for (i = 0; i < m; i++) {
      memset(curcell, 0, sizeof(curcell));
      for (j = 0; j < n; j++) {
        if (pro[j] != 0 || cmd[j][i] == 0) continue;
        if (lockcell[cmd[j][i]] == true) {
          pro[j] = i + 1;
        } else {
          if (curcell[cmd[j][i]] == true) {
            pro[j] = pro[prelock[cmd[j][i]]] = i + 1;
            lockcell[cmd[j][i]] = true;
          } else {
            curcell[cmd[j][i]] = true;
            prelock[cmd[j][i]] = j;
          }
        }
      }
    }
    for (i = 0; i < n; i++) printf("%d\n", pro[i]);
  }
  return 0;
}
