#include <bits/stdc++.h>
using namespace std;
int64_t x;
int d, n;
int a[100000], b[100000];
int64_t 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)]);
  }
}
set<pair<int, int>> s;
set<int> nzb;
int pbs[100000], ans;
int main() {
  cin >> n >> d >> x;
  initAB();
  partial_sum(b, b + n, pbs);
  for (int i = 0; i < n; ++i) {
    s.emplace(a[i], i);
    if (nzb.size() < 1000) {
      if (b[i]) nzb.emplace(i);
      ans = 0;
      for (auto&& x : nzb) ans = max(ans, a[i - x]);
      printf("%d\n", ans);
      continue;
    }
    if (!pbs[i]) goto nf;
    for (auto it = s.rbegin(); it != s.rend(); ++it) {
      if (b[i - it->second]) {
        printf("%d\n", it->first);
        goto fn;
      }
    }
  nf:
    printf("%d\n", 0);
  fn:;
  }
}
