#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, k;
  int map[110][110] = {};
  int locked[110] = {};
  int used[110] = {};
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) cin >> map[i][j];
  for (int j = 1; j <= m; j++) {
    vector<int> g[110];
    for (int i = 1; i <= n; i++) {
      if (locked[i]) continue;
      if (used[map[i][j]]) {
        locked[i] = j;
        continue;
      }
      g[map[i][j]].push_back(i);
    }
    for (int i = 1; i <= k; i++) {
      if (g[i].size() > 1) {
        for (int s = 0; s < g[i].size(); s++) {
          locked[g[i][s]] = j;
          used[i] = 1;
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) cout << locked[i] << endl;
  return 0;
}
