#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n, d, x;
int a[N], b[N], ra[N], bb[N], bp;
int getNextX() {
  x = (x * 37ll + 10007) % 1000000007;
  return x;
}
void initAB() {
  int i = 0;
  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%d", &n, &d, &x);
  initAB();
  for (int i = 0; i < n; ++i) ra[a[i]] = i;
  for (int i = 0; i < n; ++i)
    if (b[i]) bb[bp++] = i;
  for (int i = 0, j = 0, s = 30; i < n; ++i) {
    for (j = 0; j < s && j <= n; ++j) {
      int p = ra[n - j];
      if (0 <= p && p <= i && b[i - p]) {
        printf("%d\n", n - j);
        j = -1;
        break;
      }
    }
    if (j == -1) continue;
    int mx = 0;
    for (j = 0; j < bp && bb[j] <= i; ++j) mx = max(mx, a[i - bb[j]]);
    printf("%d\n", mx);
  }
  return 0;
}
