#include <bits/stdc++.h>
using namespace std;
long long n, d, x, a[112345], b[112345], loca[112345];
vector<int> loc1;
long long getNextX() {
  x = (x * 37 + 10007) % 1000000007;
  return x;
}
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++) {
    if (i < d)
      b[i] = 1;
    else
      b[i] = 0;
  }
  for (int i = 0; i < n; i++) swap(b[i], b[getNextX() % (i + 1)]);
}
long long bruteForce(int i) {
  long long bestSeen = 0;
  for (int j = 0; j < loc1.size(); j++) {
    if (i - loc1[j] >= 0) bestSeen = max(bestSeen, a[i - loc1[j]]);
  }
  return bestSeen;
}
long long faster(int i) {
  long long m = n;
  while (m > (n - sqrt(n))) {
    int j = loca[m];
    if (i - j >= 0 and b[i - j] == 1) return m;
    m--;
  }
  return bruteForce(i);
}
int main(void) {
  cin >> n >> d >> x;
  initAB();
  for (int i = 0; i < n; i++) {
    if (b[i] == 1) loc1.push_back(i);
  }
  for (int i = 0; i < n; i++) {
    loca[a[i]] = i;
  }
  for (int i = 0; i < n; i++) {
    cout << faster(i) << "\n";
  }
}
