#include <bits/stdc++.h>
const int md = 1e9 + 7;
const long long hs = 199;
const long double eps = 1e-9, pi = acos(-1);
using namespace std;
int n, d, lim = 80, ans[100002];
long long x;
vector<int> a, b, im, p;
void nextx() { x = (37 * x + 10007) % md; }
void init() {
  a.resize(n), b.resize(n), p.resize(n + 1);
  for (int i = 0; i < n; i++) a[i] = i + 1;
  for (int i = 0; i < n; i++) nextx(), swap(a[i], a[x % (i + 1)]);
  for (int i = 0; i < n; i++) b[i] = i < d;
  for (int i = 0; i < n; i++) nextx(), swap(b[i], b[x % (i + 1)]);
  for (int i = 0; i < n; i++) {
    if (b[i]) im.push_back(i);
    p[a[i]] = i;
  }
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> d >> x;
  init();
  for (int i = 0; i < n; i++) {
    bool found = false;
    for (int j = n, l = max(1, n - lim); !found && j >= l; j--) {
      if (i >= p[j] && b[i - p[j]]) {
        ans[i] = j;
        found = true;
      }
    }
    if (!found) {
      int mx = 0;
      for (int j = 0; j < im.size() && i >= im[j]; j++)
        if (a[i - im[j]] > mx) mx = a[i - im[j]];
      ans[i] = mx;
    }
  }
  for (int i = 0; i < n; i++) cout << ans[i] << '\n';
}
