#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
long long x;
int a[110000], b[110000], c[110000], pos[110000], B[110000];
int n, d, tot;
int getNextX() {
  x = (x * 37 + 10007) % 1000000007;
  return x;
}
void init() {
  for (int i = 0; i < n; i = i + 1) {
    a[i] = i + 1;
  }
  for (int i = 0; i < n; i = i + 1) {
    swap(a[i], a[getNextX() % (i + 1)]);
  }
  for (int i = 0; i < n; i = i + 1) {
    if (i < d)
      b[i] = 1;
    else
      b[i] = 0;
  }
  for (int i = 0; i < n; i = i + 1) {
    swap(b[i], b[getNextX() % (i + 1)]);
  }
}
int main() {
  scanf("%d%d%I64d", &n, &d, &x);
  init();
  for (int i = 0; i <= n - 1; ++i) pos[a[i]] = i;
  for (int i = 0; i < n; ++i)
    if (b[i]) B[++tot] = i;
  int cnt = n - 1;
  for (int i = n; i >= 1; --i) {
    for (int j = 1; j <= tot; ++j) {
      int x = pos[i] + B[j];
      if (x > cnt) break;
      if (!c[x]) c[x] = i;
    }
    while (cnt >= 0 && c[cnt]) cnt--;
    if (cnt == -1) break;
  }
  for (int i = 0; i < n; ++i) printf("%d\n", c[i]);
}
