#include <bits/stdc++.h>
using namespace std;
long long x;
int n, d;
int a[110000];
int b[110000];
int pos[110000];
int ans[110000];
long long getNextX() {
  x = (x * 37 + 10007) % 1000000007;
  return x;
}
void initAB() {
  int i;
  for (i = 0; i < n; i = i + 1) {
    a[i] = i + 1;
  }
  for (i = 0; i < n; i = i + 1) {
    swap(a[i], a[getNextX() % (i + 1)]);
  }
  for (i = 0; i < n; i = i + 1) {
    if (i < d)
      b[i] = 1;
    else
      b[i] = 0;
  }
  for (i = 0; i < n; i++) {
    swap(b[i], b[getNextX() % (i + 1)]);
  }
}
int main() {
  int i, j, k, cnt, tmp;
  vector<int> bb;
  scanf("%d%d%I64d", &n, &d, &x);
  initAB();
  bb.clear();
  for (i = 0; i < n; i++)
    if (b[i] == 1) bb.push_back(i);
  for (i = 0; i < n; i++) pos[a[i]] = i;
  cnt = 0;
  memset(ans, -1, sizeof(ans));
  for (i = 0; i < 1000 && i < n; i++) {
    for (j = 0; j <= i; j++)
      if (a[j] * b[i - j] > ans[i]) ans[i] = a[j] * b[i - j];
    cnt++;
  }
  for (i = 0; i < n; i++) {
    if (b[i] == 1) break;
    if (i >= 1000) {
      ans[i] = 0;
      cnt++;
    }
  }
  for (i = n; i >= 1; i--) {
    for (j = 0; j < bb.size(); j++) {
      tmp = pos[i] + bb[j];
      if ((tmp >= 0) && (tmp < n) && (ans[tmp] == -1)) {
        ans[tmp] = i;
        cnt++;
      }
    }
    if (cnt >= n) break;
  }
  for (i = 0; i < n; i++) printf("%d\n", ans[i]);
}
