#include <bits/stdc++.h>
using namespace std;
long long x;
int n, d;
vector<int> v;
int pos[100005], a[100005], b[100005], c[100005];
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();
  v.clear();
  int m = sqrt((double)n);
  if (d < m) {
    for (int i = 0; i < n; i++) {
      if (b[i]) v.push_back(i);
    }
    for (int i = v.size() - 1; i >= 0; i--) {
      int y = v[i];
      for (int i = 0; i + y < n; i++) {
        c[i + y] = max(c[i + y], a[i]);
      }
    }
  } else {
    for (int i = 0; i < n; i++) pos[a[i]] = i;
    for (int i = 0; i < n; i++) {
      for (int j = n; j >= 1; j--) {
        if (pos[j] <= i && b[i - pos[j]]) {
          c[i] = j;
          break;
        }
      }
    }
  }
  for (int i = 0; i < n; i++) printf("%d\n", c[i]);
  return 0;
}
