#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:500000000")
using namespace std;
int n, d, x;
int a[100009], b[100009], Pos[100009];
int getNextX() {
  x = (x * 37LL + 10007) % 1000000007;
  return x;
}
void initAB() {
  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 %d", &n, &d, &x);
  initAB();
  vector<int> ones;
  for (int i = 0; i < n; i++)
    if (b[i]) ones.push_back(i);
  set<int> bg;
  for (int i = 0; i < n; i++) Pos[a[i]] = i;
  int hash = 0;
  for (int i = 0; i < n; i++) {
    int ans = 0;
    if (d <= 15000) {
      for (auto j : ones) {
        if (j > i) break;
        if (ans < a[i - j]) ans = a[i - j];
      }
      printf("%d\n", ans);
    } else {
      bg.insert(-a[i]);
      if (bg.size() > 5000) bg.erase(--bg.end());
      for (auto a : bg) {
        if (b[i - Pos[-a]]) {
          ans = -a;
          break;
        }
      }
      printf("%d\n", ans);
    }
    hash ^= ans;
  }
}
