#include <bits/stdc++.h>
using namespace std;
const int N = 110000;
int a[N], b[N], pq[N] = {0}, to[N];
long long X, d, n;
long long getNextX() {
  X = (X * 37LL + 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() {
  scanf("%lld %lld %lld", &n, &d, &X);
  initAB();
  for (int i = 0; i < n; ++i)
    if (b[i]) {
      pq[++pq[0]] = i;
    }
  int s = 30;
  for (int i = 0; i < n; ++i) {
    to[a[i]] = i;
  }
  for (int i = 0; i < n; ++i) {
    int j;
    for (j = n; j >= n - s; j--)
      if (j > 0 && i >= to[j] && b[i - to[j]]) {
        printf("%d\n", j);
        break;
      }
    if (j < n - s) {
      int mx = 0;
      for (j = 1; j <= pq[0] && pq[j] <= i; j++) mx = max(mx, a[i - pq[j]]);
      printf("%d\n", mx);
    }
  }
  return (0);
}
