#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;
bool found;
int n, d, lim = 79, ans[100002], mx;
long long x;
vector<int> a, b, im, p;
void nextx() { x = (37 * x + 10007) % md; }
void init() {
  int temp, ind;
  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();
    ind = x % (i + 1);
    temp = a[i], a[i] = a[ind], a[ind] = temp;
  }
  for (int i = 0; i < n; i++) b[i] = i < d;
  for (int i = 0; i < n; i++) {
    nextx();
    ind = x % (i + 1);
    temp = b[i], b[i] = b[ind], b[ind] = temp;
  }
  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++) {
    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) {
      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';
}
