#include <bits/stdc++.h>
using namespace std;
const int nm = 100005;
const int mm = 100005;
int n, k, m, t, d, x, dem;
int a[nm], b[nm], vt[nm], q[nm];
bool check[nm];
int getNextX() {
  x = (x * 37ll + 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)]);
  }
  for (i = 0; i < n; i++)
    if (b[i]) q[++dem] = i;
}
int main() {
  int i, j, y, z, w, Max;
  scanf("%d%d%d", &n, &d, &x);
  initAB();
  if (dem < 3000) {
    for (i = 0; i < n; i++) {
      Max = 0;
      for (j = 1; j <= dem && q[j] <= i; j++)
        if (a[i - q[j]] > Max) Max = a[i - q[j]];
      printf("%d\n", Max);
    }
  } else {
    for (i = 1; i <= n; i++) vt[a[i]] = i;
    for (i = 0; i < n; i++) {
      for (j = n; j > 0; j--) {
        if (vt[j] <= i && b[i - vt[j]]) {
          printf("%d\n", j);
          break;
        }
      }
      if (j == 0) printf("0\n");
    }
  }
}
