#include <bits/stdc++.h>
using namespace std;
const int maxN = 100000 + 13;
int N, x, d, a[maxN], b[maxN];
int pa[maxN], pb[maxN], ind;
int getNextX() {
  x = (x * 37ll + 10007ll) % 1000000007ll;
  return x;
}
int main() {
  scanf("%d%d%d", &N, &d, &x);
  for (int i = 0; i < N; i++) a[i] = i + 1;
  for (int i = 0; i < N; i++) swap(a[i], a[getNextX() % (i + 1)]);
  for (int i = 0; i < N; i++) {
    if (i < d)
      b[i] = 1;
    else
      b[i] = 0;
  }
  for (int i = 0; i < N; i++) swap(b[i], b[getNextX() % (i + 1)]);
  for (int i = 0; i < N; i++)
    if (b[i]) pb[++ind] = i;
  for (int i = 0; i < N; i++) pa[a[i]] = i;
  int woca = 233;
  for (int i = 0; i < N; i++) {
    bool ok = false;
    for (int j = N; j >= N - woca; j--) {
      if (j > 0 && i >= pa[j] && b[i - pa[j]] == 1) {
        printf("%d\n", j);
        ok = true;
        break;
      }
    }
    if (!ok) {
      int tt = 0;
      for (int j = 1; j <= ind && pb[j] <= i; j++) tt = max(tt, a[i - pb[j]]);
      printf("%d\n", tt);
    }
  }
  return 0;
}
