#include <bits/stdc++.h>
using namespace std;
int n, d, X, A[110000], B[110000], q[110000], to[110000];
int pu;
int getNextX() {
  X = (X * 37LL + 10007) % 1000000007;
  return X;
}
int main() {
  scanf("%d%d%d", &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++) to[A[i]] = i;
  for (int i = 0; i < n; i++) {
    int j;
    for (j = n; j >= n - s; j--)
      if (j > 0 && i >= to[j] && B[i - to[j]]) {
        printf("%d\n", j);
        break;
      }
    if (j < n - s) {
      int ma = 0;
      for (j = 1; j <= q[0] && q[j] <= i; j++) ma = max(ma, A[i - q[j]]);
      printf("%d\n", ma);
    }
  }
}
