#include <bits/stdc++.h>
using namespace std;
ifstream fin("test.in");
ofstream fout("test.out");
int core[102];
int cell[102][102];
bool cellB[102];
int n, k, m;
int instr[102][102];
int main() {
  int i, j, l, celula;
  cin >> n >> m >> k;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      cin >> instr[i][j];
    }
  }
  for (j = 1; j <= m; j++) {
    for (i = 1; i <= k; i++) {
      cell[0][i] = 0;
    }
    for (i = 1; i <= n; i++) {
      if (!core[i]) {
        celula = instr[i][j];
        if (cellB[celula]) {
          core[i] = j;
        } else {
          cell[0][celula]++;
          cell[cell[0][celula]][celula] = i;
        }
      }
    }
    for (i = 1; i <= k; i++) {
      if (cell[0][i] > 1) {
        cellB[i] = true;
        for (l = 1; l <= cell[0][i]; l++) {
          core[cell[l][i]] = j;
        }
      }
    }
  }
  for (i = 1; i <= n; i++) cout << core[i] << "\n";
  return 0;
}
