#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
const int mod = 1e9 + 7;
int n, x, d, c = 33;
long long a[maxn], b[maxn], e[maxn], one[maxn];
long long ans[maxn];
int nxt() {
  x = (long long)(x * (long long)37 + 10007) % mod;
  return x;
}
void init() {
  for (int i = 0; i < n; i++) a[i] = (long long)i + 1;
  for (int i = 0; i < n; i++) swap(a[i], a[nxt() % (i + 1)]);
  for (int i = 0; i < n; i++) b[i] = (i < d) ? (long long)1 : (long long)0;
  for (int i = 0; i < n; i++) swap(b[i], b[nxt() % (i + 1)]);
  for (int i = 0; i < n; i++) {
    e[a[i]] = i;
    if (b[i]) one[++one[0]] = i;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> d >> x;
  init();
  for (int i = 0; i < n; i++) {
    int j;
    for (j = n; j >= n - c; j--)
      if (j > 0 && i >= e[j] && b[i - e[j]]) {
        ans[i] = j;
        break;
      }
    if (j < n - c) {
      long long tmp = 0;
      for (j = 1; j <= one[0] && one[j] <= i; j++)
        tmp = max(tmp, a[i - one[j]]);
      ans[i] = tmp;
    }
  }
  for (int i = 0; i < n; i++) cout << ans[i] << endl;
  return 0;
}
