#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5;
const int MV = 1e5;
const int MOD = 1e9 + 7;
int d, n;
long long x;
int a[MAX + 10], c[MAX + 10];
bool b[MAX + 10];
int where[MAX + 10];
vector<int> vec;
long long getNextX() {
  x = ((x * 37) + 10007) % MOD;
  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)]);
}
int32_t main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> d >> x;
  initAB();
  for (int i = n; i >= 1; i--)
    a[i] = a[i - 1], b[i] = b[i - 1], where[a[i]] = i;
  for (int i = 1; i <= n; i++) {
    if (b[i]) vec.push_back(i);
    for (int j = n; j >= max(1, n - 500); j--) {
      if (i - where[j] >= 0 && b[i - where[j] + 1]) {
        c[i] = j;
        break;
      }
    }
    if (!c[i]) {
      for (int u : vec) c[i] = max(c[i], a[i - u + 1]);
    }
  }
  for (int i = 1; i <= n; i++) cout << c[i] << " ";
  cout << "\n";
  return 0;
}
