#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 6.66;
const int MOD = 1e9 + 7;
const int CH = 30;
bool B[MAXN];
int C[MAXN];
int arr[MAXN];
int rev[MAXN];
vector<int> BB;
long long seed;
long long next() {
  (seed = seed * 37 + 10007) %= MOD;
  return seed;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, d;
  cin >> n >> d >> seed;
  for (int i = 0; i < n; i++) arr[i] = i + 1;
  for (int i = 0; i < n; i++) swap(arr[i], arr[next() % (i + 1)]);
  for (int i = 0; i < n; i++) B[i] = i < d;
  for (int i = 0; i < n; i++) swap(B[i], B[next() % (i + 1)]);
  for (int i = 0; i < n; i++) {
    rev[arr[i]] = i + 1;
    if (B[i]) BB.push_back(i);
    for (int j = 0; j < min(n, CH); j++)
      if (rev[n - j] && B[i - rev[n - j] + 1]) {
        C[i] = n - j;
        break;
      }
    if (!C[i])
      for (auto x : BB) C[i] = max(arr[i - x], C[i]);
  }
  for (int i = 0; i < n; i++) cout << C[i] << endl;
  return 0;
}
