#include <bits/stdc++.h>
using namespace std;
int n, d;
long long x;
int getNextX() {
  x = (x * 37 + 10007) % 1000000007;
  return x;
}
int A[1020304], B[1020304], cache[1020304], a[1020304], b[1020304],
    pos[1020304];
int main() {
  srand(time(0));
  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 = 1; i <= n; ++i) A[i] = a[i - 1];
  for (int i = 1; i <= n; ++i) pos[A[i]] = i;
  for (int i = 1; i <= n; ++i) B[i] = b[i - 1];
  int Tot = 0;
  for (int i = 1; i <= n; ++i)
    if (B[i]) cache[++Tot] = i;
  int BLK = 360;
  for (int i = 2; i <= n + 1; ++i) {
    if (d > BLK) {
      int ans = 0;
      for (int j = n; j >= 1; --j)
        if (i - pos[j] > 0) {
          if (B[i - pos[j]]) {
            ans = j;
            break;
          }
        }
      printf("%d\n", ans);
    } else {
      int ans = 0;
      for (int j = 1; j <= Tot; ++j) {
        if (cache[j] < i) {
          ans = max(ans, A[i - cache[j]]);
        } else
          break;
      }
      printf("%d\n", ans);
    }
  }
  return 0;
}
