#include <bits/stdc++.h>
using namespace std;
const int Max = 100100;
int a[100100], b[100100], n, d, c[Max], to[Max], mp_b[Max];
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 (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() {
  memset(mp_b, 0, sizeof(mp_b));
  memset(to, 0, sizeof(to));
  cin >> n >> d >> x;
  initAB();
  for (int i = 0; i < n; i++) {
    if (b[i]) mp_b[++mp_b[0]] = i;
  }
  for (int i = 0; i < n; i++) {
    to[a[i]] = i;
  }
  int s = 20;
  for (int i = 0; i < n; i++) {
    int j;
    for (j = n; j >= n - s; j--) {
      if (j > 0 && to[j] <= i && b[i - to[j]]) {
        c[i] = j;
        break;
      }
    }
    if (j < n - s) {
      c[i] = 0;
      for (int j = 1; j <= mp_b[0] && mp_b[j] <= i; j++) {
        c[i] = max(c[i], a[i - mp_b[j]]);
      }
    }
  }
  for (int i = 0; i < n; i++) printf("%d\n", c[i]);
  return 0;
}
