#include <bits/stdc++.h>
using namespace std;
int a[100010], b[100010], c[100010];
int r[100010], p[100010];
int n, d, h;
long long x;
long long getNextX() {
  x = (x * 37 + 10007) % 1000000007;
  return x;
}
void initAB() {
  int i;
  for (i = 0; i < n; i++) a[i] = i + 1;
  for (i = 0; i < n; i++) swap(a[i], a[getNextX() % (i + 1)]);
  for (i = 0; i < n; i++) {
    if (i < d)
      b[i] = 1;
    else
      b[i] = 0;
  }
  for (i = 0; i < n; i++) swap(b[i], b[getNextX() % (i + 1)]);
}
bool cmp(int i, int j) { return a[i] > a[j]; }
int main() {
  int i, j;
  int s;
  while (scanf("%d%d%I64d", &n, &d, &x) != EOF) {
    initAB();
    for (i = 0; i < n; i++) r[i] = i;
    sort(r, r + n, cmp);
    s = 0;
    for (i = 0; i < n; i++)
      if (b[i]) p[s++] = i;
    memset(c, -1, sizeof(c));
    h = n - 1;
    for (i = 0; i < n; i++) {
      for (j = 0; r[i] + p[j] <= h && j < s; j++) {
        if (c[r[i] + p[j]] == -1) c[r[i] + p[j]] = a[r[i]];
        while (h && c[h] != -1) h--;
      }
    }
    for (i = 0; i < n; i++) c[i] == -1 ? printf("0\n") : printf("%d\n", c[i]);
  }
  return 0;
}
