#include <bits/stdc++.h>
using namespace std;
const int Maxn = 1e5 + 5;
int n, d, a[Maxn], b[Maxn], c[Maxn], pos[Maxn], one[Maxn];
long long x;
int 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 (int i = 0; i < n; i++) {
    pos[a[i]] = i;
  }
  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)]);
  }
  for (i = 0; i < n; i++) {
    if (b[i] == 1) one[++one[0]] = i;
  }
}
int main() {
  scanf("%d%d%I64d", &n, &d, &x);
  initAB();
  int s = 30;
  for (int i = 0; i < n; i++) {
    int j;
    for (j = n; j >= n - s && j >= 1; j--) {
      if (pos[j] <= i && b[i - pos[j]] == 1) {
        c[i] = j;
        break;
      }
    }
    if (j < n - s) {
      int mx = 0;
      for (int k = 1; k <= one[0] && one[k] <= i; k++)
        mx = max(mx, a[i - one[k]]);
      c[i] = mx;
    }
    printf("%d\n", c[i]);
  }
  return 0;
}
