#include <bits/stdc++.h>
using namespace std;
using LL = long long;
const double PI = 2 * asin(1);
const double EPS = 1e-8;
const int INF = 0x3fffffff;
const int MX = 100000 + 10;
int g_n, g_d, g_nb;
LL g_x;
int vi_a[MX], vi_b[MX];
int vi_pa[MX], vi_nbp[MX];
bool input() {
  cin >> g_n >> g_d >> g_x;
  if (cin.eof()) return false;
  return true;
}
LL get_next_x() {
  g_x = (g_x * 37 + 10007) % 1000000007;
  return g_x;
}
void init_ab() {
  for (int i = 0; i < g_n; ++i) vi_a[i] = i + 1;
  for (int i = 0; i < g_n; ++i) swap(vi_a[i], vi_a[get_next_x() % (i + 1)]);
  for (int i = 0; i < g_n; ++i) {
    if (i < g_d)
      vi_b[i] = 1;
    else
      vi_b[i] = 0;
  }
  for (int i = 0; i < g_n; ++i) swap(vi_b[i], vi_b[get_next_x() % (i + 1)]);
}
void solve() {
  init_ab();
  int k = 0;
  for (auto &i : vi_a) vi_pa[i] = k++;
  g_nb = 0;
  for (int i = 0; i < g_n; ++i) {
    if (vi_b[i]) vi_nbp[g_nb++] = i;
  }
  const int s = 50;
  for (int i = 0; i < g_n; ++i) {
    bool f = false;
    for (int j = g_n; j >= g_n - s; --j) {
      if (vi_pa[j] <= i && vi_b[i - vi_pa[j]]) {
        f = true;
        printf("%d\n", j);
        break;
      }
    }
    if (!f) {
      int ans = 0;
      for (int j = 0; j < g_nb && vi_nbp[j] <= i; ++j)
        ans = max(ans, vi_a[i - vi_nbp[j]]);
      printf("%d\n", ans);
    }
  }
}
int main() {
  while (input()) {
    solve();
  }
  return 0;
}
