#include <bits/stdc++.h>
using namespace std;
const double eps = 0.000000000000001;
long long x;
int n, d;
int a[100010], b[100010], position[100010];
int getNextX() {
  x = (x * 37LL + 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", &n, &d);
  scanf("%lld", &x);
  int i, j;
  initAB();
  vector<int> ones;
  for (i = 0; i < n; i++) {
    if (b[i]) {
      ones.push_back(i);
    }
  }
  for (i = 0; i < n; i++) {
    position[a[i]] = i;
  }
  for (i = 0; i < n; i++) {
    int c = 0;
    if (d < 317) {
      for (j = 0; j < ones.size() && i - ones[j] >= 0; j++) {
        c = max(c, a[i - ones[j]]);
      }
    } else {
      for (j = n; j >= 1; j--) {
        int lol = position[j];
        if (i - lol >= 0 && b[i - lol]) {
          c = j;
          break;
        }
      }
    }
    printf("%d\n", c);
  }
  return 0;
}
