#include <bits/stdc++.h>
using namespace std;
int a[111111], b[111111], q[111111], to[111111];
int n, d;
long long x;
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 = i + 1) {
    swap(b[i], b[getNextX() % (i + 1)]);
  }
}
int main() {
  int i, j;
  while (scanf("%d%d%I64d", &n, &d, &x) != EOF) {
    memset(q, 0, sizeof(q));
    initAB();
    for (i = 0; i < n; i++) to[a[i]] = i;
    for (i = 0; i < n; i++)
      if (b[i]) q[++q[0]] = i;
    int s = 233;
    for (i = 0; i < n; i++) {
      for (j = n; j > n - s && j > 0; j--)
        if (to[j] <= i && b[i - to[j]]) {
          printf("%d\n", j);
          break;
        }
      if (!(j > n - s && j > 0)) {
        int ma = 0;
        for (j = 1; j <= q[0] && q[j] <= i; j++)
          if (a[i - q[j]] > ma) ma = a[i - q[j]];
        printf("%d\n", ma);
      }
    }
  }
  return 0;
}
