#include <bits/stdc++.h>
using namespace std;
int a[101][101];
int u[101];
int uu[101];
int d[101];
int b[101];
int t[101];
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  for (long long i = 1; i <= n; i++)
    for (long long j = 1; j <= m; j++) cin >> a[i][j];
  for (long long j = 1; j <= m; j++) {
    for (long long y = 1; y <= k; y++) u[y] = 0;
    for (long long i = 1; i <= n; i++)
      if (!t[i] && a[i][j]) {
        if (u[a[i][j]])
          t[u[a[i][j]]] = j, t[i] = j, d[a[i][j]] = 1;
        else if (d[a[i][j]])
          t[i] = j;
        else
          u[a[i][j]] = i;
      }
  }
  for (long long i = 1; i <= n; i++) cout << t[i] << endl;
}
