#include <bits/stdc++.h>
using namespace std;
const int MAX_N = (int)1e5 + 123;
const int mod = (int)1e9 + 7;
int n, d, x;
int a[MAX_N], b[MAX_N];
int getNextX() {
  x = (x * 37ll + 10007ll) % mod;
  return x;
}
int where[MAX_N], ans[MAX_N];
void initAB() {
  scanf("%d%d%d", &n, &d, &x);
  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);
  for (int i = 0; i < n; i++) swap(b[i], b[getNextX() % (i + 1)]);
  for (int i = 0; i < n; i++) where[a[i]] = i;
  const int magic = 350;
  vector<int> good;
  for (int i = 0; i < n; i++) {
    ans[i] = 0;
    if (b[i]) good.push_back(i);
    for (int j = n; j > max(n - magic, 0); j--)
      if (where[j] <= i && b[i - where[j]]) {
        ans[i] = j;
        break;
      }
    if (ans[i] == 0) {
      for (auto j : good) ans[i] = max(ans[i], a[i - j]);
    }
  }
  for (int i = 0; i < n; i++) printf("%d\n", ans[i]);
}
int main() {
  initAB();
  return 0;
}
