#include <bits/stdc++.h>
using namespace std;
int n, d;
long long x;
vector<int> a, b, D, S, Sb;
long long getNextX() {
  x = (x * 37 + 10007) % 1000000007;
  return x;
}
void initAB() {
  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)]);
}
int main() {
  cin >> n >> d >> x;
  a = vector<int>(n);
  b = vector<int>(n);
  D = vector<int>(n);
  S = vector<int>(n + 4);
  initAB();
  for (int i = 0; i < n; ++i) S[a[i]] = i;
  for (int i = 0; i < n; ++i)
    if (b[i]) Sb.push_back(i);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < 30; ++j)
      if (n - j >= 0 and S[n - j] <= i and b[i - S[n - j]] == 1) {
        D[i] = n - j;
        break;
      }
    if (D[i] == 0)
      for (int j = 0; j < int(Sb.size()) and Sb[j] <= i; ++j)
        D[i] = max(D[i], a[i - Sb[j]]);
  }
  for (int i = 0; i < n; ++i) cout << D[i] << endl;
}
