#include <bits/stdc++.h>
using namespace std;
bool Check(int N, int pos) { return (bool)(N & (1 << pos)); }
int Set(int N, int pos) { return (N | (1 << pos)); }
int fx[] = {-1, 0, 1, 0};
int fy[] = {0, 1, 0, -1};
inline long long BigMod(long long B, long long P, long long M) {
  long long R = 1;
  while (P > 0) {
    if (P % 2 == 1) {
      R = (R * B) % M;
    }
    P /= 2;
    B = (B * B) % M;
  }
  return R;
}
int ara[104][104];
int mark[104];
int row[104];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(nullptr);
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> ara[i][j];
    }
  }
  for (int j = 1; j <= m; j++) {
    vector<int> G[104];
    for (int i = 1; i <= n; i++) {
      if (row[i]) continue;
      if (mark[ara[i][j]]) {
        row[i] = j;
        continue;
      }
      G[ara[i][j]].push_back(i);
    }
    for (int i = 1; i <= k; i++) {
      if (G[i].size() <= 1) continue;
      for (int x = 0; x < G[i].size(); x++) {
        row[G[i][x]] = j;
      }
      mark[i] = 1;
    }
  }
  for (int i = 1; i <= n; i++) cout << row[i] << "\n";
}
