#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const long long int N = 1e5 + 5;
long long int a[N], b[N], n, d, x;
long long int getNextX() {
  x = (x * 37 + 10007) % 1000000007;
  return x;
}
void initAB() {
  for (long long int i = 0; i < n; i++) {
    a[i] = i + 1;
  }
  for (long long int i = 0; i < n; i++) {
    swap(a[i], a[getNextX() % (i + 1)]);
  }
  for (long long int i = 0; i < n; i++) {
    if (i < d)
      b[i] = 1;
    else
      b[i] = 0;
  }
  for (long long int i = 0; i < n; i++) {
    swap(b[i], b[getNextX() % (i + 1)]);
  }
}
long long int pos[N];
vector<long long int> bb;
long long int c[N];
void solve() {
  cin >> n >> d >> x;
  initAB();
  for (long long int i = 0; i <= n - 1; i++) {
    if (b[i]) bb.push_back(i);
  }
  for (long long int i = 0; i <= n - 1; i++) {
    pos[a[i]] = i;
  }
  if (bb.size() <= 500) {
    for (long long int i = 0; i <= n - 1; i++) {
      for (long long int j : bb) {
        if (j > i) break;
        c[i] = max(c[i], a[i - j]);
      }
    }
  } else {
    for (long long int i = 0; i <= n - 1; i++)
      for (long long int j = n; j >= 1; j--) {
        long long int p = pos[j];
        if (p <= i && b[i - p]) {
          c[i] = j;
          break;
        }
      }
  }
  for (long long int i = 0; i <= n - 1; i++) cout << c[i] << " ";
}
signed main() {
  ios ::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  clock_t clk = clock();
  long long int t;
  t = 1;
  while (t--) {
    solve();
  }
  cerr << (double)(clock() - clk) / CLOCKS_PER_SEC;
  return 0;
}
