#include <bits/stdc++.h>
using namespace std;
int n, d;
int a[210000];
int b[210000];
long long int x;
void swap(int &a, int &b) {
  int c;
  c = a;
  a = b;
  b = c;
}
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 next_one[210000];
struct xy {
  int x, y;
} aa[210000];
bool sort_x(xy a, xy b) {
  if (a.x < b.x) return 1;
  return 0;
}
bool is_done[210000];
int c[210000];
int bb[210000];
int teleport[210000];
int get_tel(int w) {
  int noww;
  int bw;
  int rw;
  noww = w;
  while (1) {
    if (teleport[noww] == -1) break;
    noww = teleport[noww];
  }
  rw = noww;
  noww = w;
  while (1) {
    if (teleport[noww] == -1) break;
    bw = noww;
    noww = teleport[noww];
    if (bw != n + 1) teleport[bw] = rw;
  }
  return rw;
}
int main() {
  int i, j;
  int now;
  int one_index;
  scanf("%d%d%d", &n, &d, &x);
  initAB();
  one_index = n + 1;
  for (i = n; i >= 0; i--) {
    next_one[i] = one_index;
    if (b[i - 1] == 1) one_index = i;
  }
  for (i = 1; i <= n; i++) {
    aa[i].x = a[i - 1];
    aa[i].y = i;
    bb[i] = b[i - 1];
  }
  sort(aa + 1, aa + n + 1, sort_x);
  for (i = 1; i <= n + 1; i++) {
    c[i] = -1;
    teleport[i] = -1;
  }
  for (i = n; i >= 1; i--) {
    now = next_one[0];
    while (1) {
      if (now > n - aa[i].y + 1) break;
      if (c[now + aa[i].y - 1] == -1) {
        c[now + aa[i].y - 1] = aa[i].x;
        teleport[now + aa[i].y - 1] = now + aa[i].y;
      } else {
        now = get_tel(now + aa[i].y - 1) - aa[i].y + 1;
        if (now == n + 1) break;
        if (bb[now] == 0) now = next_one[now];
        continue;
      }
      now = next_one[now];
    }
  }
  for (i = 1; i <= n; i++) {
    if (c[i] == -1) c[i] = 0;
    printf("%d\n", c[i]);
  }
  return 0;
}
