#include <bits/stdc++.h>
using namespace std;
int a[100005], b[100005], n, d;
long long x;
long long 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 pos[100005], cot[100005];
int main() {
  cin >> n >> d >> x;
  initAB();
  int s = 60, cnt = 0;
  for (int i = 0; i < n; ++i) pos[a[i]] = i;
  for (int i = 0; i < n; ++i)
    if (b[i]) cot[cnt++] = i;
  for (int i = 0; i < n; ++i) {
    int ans = 0;
    for (int j = n - s; j <= n; ++j) {
      if (j <= 0) continue;
      if (pos[j] <= i && b[i - pos[j]]) ans = j;
    }
    if (ans == 0) {
      for (int j = 0; j < cnt && cot[j] <= i; ++j)
        ans = max(ans, a[i - cot[j]]);
    }
    printf("%d\n", ans);
  }
  return 0;
}
