#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 3;
int ans[N];
bool b[N], a[N];
int z[N][N];
int main() {
  int n, m;
  int k;
  cin >> n >> m >> k;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) cin >> z[j][i];
  for (int i = 0; i < m; ++i) {
    map<int, set<int> > q;
    map<int, set<int> >::iterator it;
    for (int j = 0; j < n; ++j) {
      int x;
      x = z[i][j];
      if (x && !b[j]) {
        if (!a[x])
          q[x].insert(j);
        else {
          b[j] = true;
          ans[j] = i + 1;
        }
      }
    }
    for (it = q.begin(); it != q.end(); it++) {
      set<int>& s = it->second;
      if (s.size() > 1) {
        a[it->first] = true;
        for (set<int>::iterator jt = s.begin(); jt != s.end(); jt++) {
          b[*jt] = true;
          ans[*jt] = i + 1;
        }
      }
    }
  }
  for (int i = 0; i < n; ++i) cout << ans[i] << endl;
  return 0;
}
