#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9;
const int mod = (int)1e9 + 7;
const double pi = acos(-1.0);
const double eps = 1e-9;
int n, m, k;
int a[200][200];
int ans[200], b[200];
vector<int> g[200];
int main() {
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) cin >> a[i][j];
  }
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < 200; j++) g[j].clear();
    for (int j = 0; j < n; j++)
      if (a[j][i] && !ans[j]) {
        g[a[j][i]].push_back(j);
      }
    for (int j = 1; j <= k; j++) {
      if (g[j].size() == 1) {
        int v = g[j][0];
        if (b[j]) {
          ans[v] = i + 1;
        }
      } else if (g[j].size() > 1) {
        b[j] = 1;
        for (int l = 0; l < g[j].size(); l++) ans[g[j][l]] = i + 1;
      }
    }
  }
  for (int i = 0; i < n; i++) cout << ans[i] << "\n";
  return 0;
}
