#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
const int MOD = 1000000007;
int n, d, a[N], b[N], p[N], ans[N];
long long x;
vector<int> v;
long long getNextX() {
  x = (x * 37 + 10007) % 1000000007;
  return x;
}
void initAB() {
  int i;
  for (i = 0; i < n; i = i + 1) {
    a[i] = i + 1;
  }
  for (i = 0; i < n; i = i + 1) {
    swap(a[i], a[getNextX() % (i + 1)]);
  }
  for (i = 0; i < n; i = i + 1) {
    if (i < d)
      b[i] = 1;
    else
      b[i] = 0;
  }
  for (i = 0; i < n; i = i + 1) {
    swap(b[i], b[getNextX() % (i + 1)]);
  }
}
int main() {
  scanf("%d %d %I64d", &n, &d, &x);
  initAB();
  for (int i = 0; i < n; i++) {
    p[a[i]] = i;
  }
  for (int i = 0; i < n; i++) {
    if (b[i]) v.push_back(i);
  }
  int cnt = 0;
  if (d < 400) {
    for (int i = n; i >= 1; i--) {
      int pos = p[i];
      for (int j = 0; j < v.size(); j++) {
        if (v[j] + pos >= n) break;
        if (ans[v[j] + pos]) continue;
        ans[v[j] + pos] = i;
        cnt++;
      }
      if (cnt == n) break;
    }
  } else {
    for (int i = 0; i < n; i++) {
      int ret = 0;
      for (int j = n; j >= 1; j--) {
        if (i - p[j] >= 0 && b[i - p[j]]) {
          ret = j;
          break;
        }
      }
      ans[i] = ret;
    }
  }
  for (int i = 0; i < n; i++) printf("%d ", ans[i]);
  return 0;
}
