#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e9;
const long double E = 1e-11;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int n, m, k;
  cin >> n >> m >> k;
  bool block[k];
  memset(block, 0, sizeof(block));
  ;
  int ar[n][m];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> ar[i][j];
  int ans[n];
  memset(ans, 0, sizeof(ans));
  ;
  for (int i = 0; i < m; i++) {
    set<int> s1, s2;
    for (int j = 0; j < n; j++)
      if (ans[j] == 0 && ar[j][i] != 0) {
        if (block[ar[j][i] - 1]) {
          ans[j] = i + 1;
          continue;
        }
        if (s1.find(ar[j][i]) != s1.end()) s2.insert(ar[j][i]);
        s1.insert(ar[j][i]);
      }
    for (int j = 0; j < n; j++)
      if (ans[j] == 0)
        if (s2.find(ar[j][i]) != s2.end()) ans[j] = i + 1;
    for (set<int>::iterator it = s2.begin(); it != s2.end(); it++)
      block[*it - 1] = true;
  }
  for (int i = 0; i < n; i++) cout << ans[i] << "\n";
}
