#include <bits/stdc++.h>
using namespace std;
long long x;
long long d;
long long n;
long long a[100 * 1000 + 5];
long long b[100 * 1000 + 5];
long long q[100 * 1000 + 5] = {0};
long long prv[100 * 1000 + 5] = {0};
long long getNextX() {
  x = (x * 37 + 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(int argc, const char* argv[]) {
  cin >> n >> d >> x;
  set<long long> myset;
  initAB();
  for (int i = 0; i < n; i++) {
    q[a[i]] = i;
  }
  if (d > sqrt(double(n))) {
    for (int i = 0; i < n; i++) {
      bool b2 = false;
      myset.insert(a[i]);
      for (auto it = myset.rbegin(); it != myset.rend(); it++) {
        long long z = *it;
        int indz = q[z];
        if (b[i - indz] == 1) {
          b2 = true;
          cout << z << endl;
          break;
        }
      }
      if (b2 == false) cout << 0 << endl;
    }
  } else {
    int prevn = -1;
    for (int i = 0; i < n; i++) {
      prv[i] = prevn;
      if (b[i] == 1) {
        prevn = i;
      }
    }
    for (int i = 0; i < n; i++) {
      long long mx = -1;
      for (int j = 0; j <= i;) {
        mx = max(mx, a[j] * b[i - j]);
        int u = prv[i - j];
        if (u == -1) break;
        j = i - u;
      }
      cout << mx << endl;
    }
  }
  return 0;
}
