#include <bits/stdc++.h>
using namespace std;
int N, D;
long long x;
int A[100005];
int B[100005];
set<pair<int, int>, greater<pair<int, int> > > S;
vector<int> ones;
long long getnextx() {
  x = (x * 37 + 10007) % 1000000007;
  return x;
}
void initAB() {
  int i;
  for (i = 0; i < N; i++) A[i] = i + 1;
  for (i = 0; i < N; i++) swap(A[i], A[getnextx() % (i + 1)]);
  for (i = 0; i < N; i++)
    if (i < D)
      B[i] = 1;
    else
      B[i] = 0;
  for (i = 0; i < N; i++) swap(B[i], B[getnextx() % (i + 1)]);
}
int main() {
  cin >> N >> D >> x;
  initAB();
  if (D < 500) {
    for (int i = 0; i < N; i++) {
      if (B[i]) ones.push_back(i);
    }
    for (int i = 0; i < N; i++) {
      int ans = 0;
      for (typeof(ones.begin()) it = ones.begin(); it != ones.end(); it++) {
        int diff = i - (*it);
        if (diff < 0) break;
        if (ans < A[diff]) ans = A[diff];
      }
      cout << ans << '\n';
    }
    return 0;
  }
  for (int i = 0; i < N; i++) {
    S.insert(pair<int, int>(A[i], i));
    int ans = 0;
    for (typeof(S.begin()) it = S.begin(); it != S.end(); it++) {
      if (B[i - it->second]) {
        ans = it->first;
        break;
      }
    }
    cout << ans << '\n';
  }
  return 0;
}
