#include <bits/stdc++.h>
using namespace std;
long long n, x, d, a[100000], b[100000], ans[100000], bb[100000];
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) {
    swap(a[i], a[getNextX() % (i + 1)]);
  }
  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("%lld %lld %lld", &n, &d, &x) != EOF) {
    initAB();
    int k = 100;
    memset(ans, 0, sizeof(ans));
    for (int i = int(0); i < int(n); i++) {
      if (a[i] >= n - k) {
        for (int j = int(0); j < int(n); j++) {
          if (i + j >= n) break;
          if (b[j]) {
            ans[i + j] = max(ans[j + i], a[i]);
          }
        }
      }
    }
    int bc = 0;
    for (int i = int(0); i < int(n); i++) {
      if (b[i]) bb[bc++] = i;
      if (ans[i] == 0) {
        for (int j = int(0); j < int(bc); j++) {
          ans[i] = max(ans[i], a[i - bb[j]]);
        }
      }
      printf("%d\n", ans[i]);
    }
  }
  return 0;
}
