#include <bits/stdc++.h>
using namespace std;
const int nm = 100002;
int n, d;
long long x;
int a[nm], b[nm], vt[nm];
int c[nm];
int nc;
int getNextX() {
  x = (x * 37 + 10007) % 1000000007;
  return x;
}
void init() {
  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 = i + 1) {
    swap(b[i], b[getNextX() % (i + 1)]);
  }
}
int main() {
  scanf("%d%d%I64d", &n, &d, &x);
  init();
  int i, j, k;
  for (i = 0; i < n; ++i) {
    vt[a[i]] = i;
    if (b[i]) c[++nc] = i;
  }
  for (i = 0; i < n; ++i) {
    for (j = n; j > n - 50 && j > 0; --j)
      if (vt[j] <= i && b[i - vt[j]]) break;
    if (j > n - 50 && j > 0) {
      printf("%d\n", j);
      continue;
    }
    k = 0;
    for (j = 1; j <= nc && c[j] <= i; ++j) k = max(k, a[i - c[j]]);
    printf("%d\n", k);
  }
}
