#include <bits/stdc++.h>
using namespace std;
int x, n, d;
int getNextX() {
  x = (x * (long long)37 + 10007) % 1000000007;
  return x;
}
int a[112345];
bool b[112345];
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();
  int sqrn = sqrt((double)n);
  if (d <= sqrn) {
    vector<int> pos;
    pos.reserve(d);
    for (int m = 0; m < int(n); m++) {
      if (b[m]) pos.push_back(m);
      int ans = 0;
      for (auto x : pos) ans = max(ans, a[m - x]);
      printf("%d\n", ans);
    }
  } else {
    map<int, int> M;
    for (int m = 0; m < int(n); m++) {
      M[-a[m]] = m;
      int ans = 0;
      for (auto x : M)
        if (b[m - x.second]) {
          ans = -x.first;
          break;
        }
      printf("%d\n", ans);
    }
  }
}
