#include <bits/stdc++.h>
using namespace std;
int n, m, k, c[200][200], a[200], b[200], d[200];
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) scanf("%d", &c[i][j]);
  for (int i = 0; i < m; ++i) {
    for (int j = 0; j < n; ++j) {
      int x = c[j][i];
      if (x != 0 && a[j + 1] == 0)
        if (b[x] == -1)
          a[j + 1] = i + 1;
        else
          b[x] = j + 1;
    }
    for (int j = 0; j < n; ++j) {
      int x = c[j][i];
      if (x != 0 && a[j + 1] == 0 && (b[x] == -1 || b[x] != j + 1)) {
        b[x] = -1;
        a[j + 1] = i + 1;
      }
    }
  }
  for (int i = 1; i < n + 1; ++i) printf("%d\n", a[i]);
  return 0;
}
