#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9;
const long long llinf = (long long)9e18;
const int N = 111;
int a[N][N], ans[N];
int main() {
  int n, m, k;
  scanf("%d %d %d", &n, &m, &k);
  vector<char> us(k + 1, 0);
  for (int i = 0; i < n; i++) ans[i] = -1;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) scanf("%d", &a[i][j]);
  for (int j = 0; j < m; j++) {
    vector<int> cur[N];
    for (int i = 0; i < n; i++)
      if (a[i][j] != 0 && ans[i] == -1) {
        int to = a[i][j];
        if (us[to] == 1) ans[i] = j + 1;
        cur[to].push_back(i);
      }
    for (int i = 1; i <= k; i++)
      if (cur[i].size() != 0)
        if (cur[i].size() > 1) {
          us[i] = 1;
          for (int ii = 0; ii < (int)cur[i].size(); ii++)
            ans[cur[i][ii]] = j + 1;
        }
  }
  for (int i = 0; i < n; i++) printf("%d\n", (ans[i] != -1 ? ans[i] : 0));
  return 0;
}
