#include <bits/stdc++.h>
using namespace std;
const int N = 100050;
int n, d, x;
int a[N];
int b[N];
int to[N];
int q[N];
int getNextX() {
  x = (x * 37ll + 10007) % 1000000007;
  return x;
}
void initAB() {
  for (int i = 0; i < n; ++i) a[i] = i + 1;
  for (int i = 0; i < n; ++i) {
    swap(a[i], a[getNextX() % (i + 1)]);
    b[i] = (i < d);
  }
  for (int i = 0; i < n; ++i) swap(b[i], b[getNextX() % (i + 1)]);
}
int main() {
  scanf("%d%d%d", &n, &d, &x);
  initAB();
  for (int i = 0; i < n; ++i) {
    to[a[i]] = i;
    if (b[i]) q[++q[0]] = i;
  }
  for (int i = 0; i < n; ++i) {
    int j, mx = 0;
    for (j = n; j >= max(1, n - 30); --j) {
      if (i >= to[j] && b[i - to[j]]) {
        printf("%d\n", j);
        goto end;
      }
    }
    for (j = 1; j <= q[0] && q[j] <= i; ++j) mx = max(mx, a[i - q[j]]);
    printf("%d\n", mx);
  end:;
  }
  return 0;
}
