#include <bits/stdc++.h>
int n, d, x, a[100000 + 10], b[100000 + 10], q[100000 + 10], to[100000 + 10];
using namespace std;
inline void swap(int& x, int& y) {
  int t = x;
  x = y;
  y = t;
}
inline int getnextx() { return x = (x * 37ll + 10007) % 1000000007; }
inline void initab() {
  for (int i = 0; i < n; ++i) a[i] = i + 1;
  for (int i = 0; i < n; ++i) swap(a[i], a[getnextx() % (i + 1)]);
  for (int i = 0; i < n; ++i) b[i] = i < d ? 1 : 0;
  for (int i = 0; i < n; ++i) swap(b[i], b[getnextx() % (i + 1)]);
}
int main() {
  scanf("%d%d%d", &n, &d, &x);
  initab();
  for (int i = 0; i < n; ++i)
    if (b[i]) q[++q[0]] = i;
  for (int i = 0; i < n; ++i) to[a[i]] = i;
  for (int i = 0; i < n; ++i) {
    bool f = 0;
    for (int j = n; j >= n - 30 && j; --j)
      if (i >= to[j] && b[i - to[j]]) {
        printf("%d\n", j);
        f = 1;
        break;
      }
    if (!f) {
      int ans = 0;
      for (int j = 1; j <= q[0] && q[j] <= i; ++j)
        if (a[i - q[j]] > ans) ans = a[i - q[j]];
      printf("%d\n", ans);
    }
  }
  return 0;
}
