#include <bits/stdc++.h>
using namespace std;
long long x;
int n, d, a[100005], b[100005], c[100005], pos[100005];
int getNextX() {
  x = (x * 37 + 10007) % 1000000007;
  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)]);
  }
}
int main() {
  scanf("%d%d%lld", &n, &d, &x);
  initAB();
  for (int i = 0; i < n; ++i) pos[a[i]] = i;
  vector<int> vc;
  for (int i = 0; i < n; ++i)
    if (b[i]) vc.push_back(i);
  int s = 30;
  for (int i = 0; i < n; ++i) {
    int j;
    for (j = n; j >= n - s; --j) {
      if (j > 0 && i >= pos[j] && b[i - pos[j]]) {
        printf("%d\n", j);
        break;
      }
    }
    if (j < n - s) {
      int ans = 0;
      for (j = 0; j < vc.size() && vc[j] <= i; ++j) {
        ans = max(ans, a[i - vc[j]]);
      }
      printf("%d\n", ans);
    }
  }
  exit(0);
}
