#include <bits/stdc++.h>
using namespace std;
const int M = 110000;
long long a[M], b[M], c[M], be[M];
long long n, d, x;
long long getNextX() {
  x = (x * 37 + 10007) % 1000000007;
  return x;
}
void initAB() {
  long long i;
  for (i = 0; i < n; i = i + 1) {
    a[i] = i + 1;
  }
  for (i = 0; i < n; i = i + 1) {
    swap(a[i], a[getNextX() % (i + 1)]);
  }
  for (i = 0; i < n; i = i + 1) {
    if (i < d)
      b[i] = 1;
    else
      b[i] = 0;
  }
  for (i = 0; i < n; i = i + 1) {
    swap(b[i], b[getNextX() % (i + 1)]);
  }
}
int main() {
  long long i, j, k;
  while (~scanf("%I64d%I64d%I64d", &n, &d, &x)) {
    initAB();
    vector<int> vt;
    memset(be, 0, sizeof(be));
    int cnt = 0;
    for (i = 0; i < n; i++)
      if (b[i]) cnt++;
    if (cnt <= sqrt(n)) {
      for (i = 0; i < n; i++)
        if (b[i]) vt.push_back(i);
      for (i = 0; i < n; i++) {
        long long mx = 0;
        for (j = 0; j < vt.size(); j++) {
          k = vt[j];
          if (k > i) break;
          c[i] = max(c[i], a[i - k]);
        }
      }
    } else {
      vector<pair<int, int> > vc;
      for (i = 0; i < n; i++) vc.push_back(make_pair(a[i], i));
      sort(vc.begin(), vc.end());
      for (i = 0; i < n; i++) {
        for (j = n - 1; j >= 0; j--) {
          if (vc[j].second <= i && b[i - vc[j].second]) {
            c[i] = vc[j].first;
            break;
          }
        }
      }
    }
    for (i = 0; i < n; i++) cout << c[i] << endl;
  }
  return 0;
}
