#include <bits/stdc++.h>
using namespace std;
long long a[100005];
long long b[100005];
long long n, d, x;
long long pos[100005];
long long getNextX() {
  x = (x * 37 + 10007) % 1000000007;
  return x;
}
void initAB() {
  for (int i = 0; i < n; i = i + 1) {
    a[i] = i + 1;
  }
  for (int i = 0; i < n; i = i + 1) {
    int index;
    index = getNextX() % (i + 1);
    swap(a[i], a[index]);
  }
  for (int i = 0; i < n; i = i + 1) {
    if (i < d)
      b[i] = 1;
    else
      b[i] = 0;
  }
  for (int i = 0; i < n; i = i + 1) {
    swap(b[i], b[getNextX() % (i + 1)]);
  }
}
int main() {
  while (scanf("%I64d%I64d%I64d", &n, &d, &x) == 3) {
    initAB();
    for (long long i = 0; i < n; i++) pos[a[i]] = i;
    vector<int> s;
    for (long long i = 0; i < n; i++)
      if (b[i]) s.push_back(i);
    int t = 40;
    for (long long i = 0; i < n; i++) {
      long long j;
      for (j = n; j >= n - t; --j)
        if (j > 0 && i >= pos[j] && b[i - pos[j]]) {
          printf("%I64d\n", j);
          break;
        }
      if (j < n - t) {
        long long ans = 0;
        for (long long j = 0; j < s.size() && i >= s[j]; ++j)
          ans = max(ans, a[i - s[j]]);
        printf("%I64d\n", ans);
      }
    }
  }
  return 0;
}
