#include <bits/stdc++.h>
using namespace std;
template <typename T>
T read() {
  T x;
  cin >> x;
  return x;
}
int dx[] = {0, 0, 1, -1, 1, -1, 1, -1}, dy[] = {-1, 1, 0, 0, 1, -1, -1, 1};
void run();
int main() {
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(16);
  run();
}
long long x;
int n, d, a[100100], b[100100], pos[100100];
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)]);
  }
}
vector<int> ones;
void run() {
  cin >> n >> d >> x;
  initAB();
  for (int i = 0; i < n; ++i)
    if (b[i]) ones.push_back(i);
  for (int i = 0; i < n; ++i) pos[a[i]] = i;
  int onecnt = 0;
  for (int i = 0; i < n; ++i) {
    bool found = 0;
    for (int x = n; x > max(0, n - 200); --x) {
      if (i >= pos[x] && b[i - pos[x]]) {
        found = 1;
        cout << x << "\n";
        break;
      }
    }
    if (found) continue;
    int ans = 0;
    for (int j : ones) {
      if (j > i) break;
      ans = max(ans, a[i - j]);
    }
    cout << ans << "\n";
  }
}
