#include <bits/stdc++.h>
using namespace std;
int n, d;
long long x;
int a[100005], b[100005];
int a_index[100005], q[100005];
long long getNextX() {
  x = (x * 37 + 10007) % 1000000007;
  return x;
}
void initAB() {
  for (int i = 0; i < n; i = i + 1) {
    a[i] = i + 1;
  }
  for (int i = 0; i < n; i = i + 1) {
    swap(a[i], a[getNextX() % (i + 1)]);
  }
  for (int i = 0; i < n; i = i + 1) {
    if (i < d)
      b[i] = 1;
    else
      b[i] = 0;
  }
  for (int i = 0; i < n; i = i + 1) {
    swap(b[i], b[getNextX() % (i + 1)]);
  }
}
int main() {
  cin >> n >> d >> x;
  initAB();
  for (int i = 0; i < n; i++) {
    a_index[a[i]] = i;
  }
  int s = 30;
  for (int i = 0; i < n; i++)
    if (b[i]) q[++q[0]] = i;
  for (int i = 0; i < n; i++) {
    int j;
    for (j = n; j >= n - s; j--)
      if (j > 0 && i >= a_index[j] && b[i - a_index[j]]) {
        printf("%d\n", j);
        break;
      }
    if (j < n - s) {
      int ma = 0;
      for (j = 1; j <= q[0] && q[j] <= i; j++) ma = max(ma, a[i - q[j]]);
      printf("%d\n", ma);
    }
  }
  return 0;
}
