#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f, mod = 1e9 + 7;
const int N = 109;
int ans[N], on[N], loc[N], a[N][N];
int n, m, k;
int main() {
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) cin >> a[i][j];
  for (int j = 1; j <= m; j++) {
    memset(on, 0, sizeof(on));
    for (int i = 1; i <= n; i++)
      if (ans[i] == 0 && a[i][j]) {
        if (loc[a[i][j]])
          ans[i] = j;
        else
          on[a[i][j]]++;
      }
    for (int i = 1; i <= n; i++)
      if (ans[i] == 0 && a[i][j]) {
        if (on[a[i][j]] >= 2) ans[i] = j, loc[a[i][j]] = 1;
      }
  }
  for (int i = 1; i <= n; i++) cout << ans[i] << endl;
  return 0;
}
