#include <bits/stdc++.h>
using namespace std;
int a[100100], b[100100];
int q[100100], is[100100];
int x, d, n;
int getNextX() {
  x = (x * 37ll + 10007) % 1000000007;
  return x;
}
int main(int argc, char const *argv[]) {
  cin >> n >> d >> x;
  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)]);
  }
  for (int i = 0; i < n; i++) {
    if (b[i]) {
      q[++q[0]] = i;
    }
  }
  int s = 30;
  for (int i = 0; i < n; i++) {
    is[a[i]] = i;
  }
  for (int i = 0; i < n; i++) {
    int j;
    for (j = n; j >= n - s; j--) {
      if (j > 0 && i >= is[j] && b[i - is[j]]) {
        printf("%d\n", j);
        break;
      }
    }
    if (j < n - s) {
      int ans = 0;
      for (j = 1; j <= q[0] && q[j] <= i; j++) {
        ans = max(ans, a[i - q[j]]);
      }
      printf("%d\n", ans);
    }
  }
  return 0;
}
