#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
long long x;
int n, d, a[maxn], b[maxn], pos[maxn];
long long getNextX() {
  x = (x * 37 + 10007) % 1000000007;
  return x;
}
void swap(int &a, int &b) {
  int t = a;
  a = b;
  b = t;
}
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 one[maxn], c[maxn];
int main() {
  cin >> n >> d >> x;
  initAB();
  for (int i = 0; i < n; i++) pos[a[i]] = i;
  int tot = 0;
  for (int i = 0; i < n; i++)
    if (b[i]) one[++tot] = i;
  memset(c, -1, sizeof(c));
  int cnt = 10000005;
  for (int i = n; i > 0 && cnt > 0; i--) {
    for (int j = 1; j <= tot && pos[i] + one[j] < n; j++)
      c[pos[i] + one[j]] = max(c[pos[i] + one[j]], i), cnt--;
  }
  for (int i = 0; i < n; i++) {
    if (c[i] < 0) {
      c[i] = 0;
      for (int j = 1; j <= tot && one[j] <= i; j++)
        c[i] = max(c[i], a[i - one[j]]);
    }
    printf("%d\n", c[i]);
  }
  return 0;
}
