#include <bits/stdc++.h>
using namespace std;
const int LIM = 100005;
long long a[LIM], b[LIM], n, d, x, c[LIM];
long long getNextX() {
  x = (x * 37 + 10007) % 1000000007;
  return x;
}
void initAB() {
  int i;
  for (i = 0; i < n; i = i + 1) {
    a[i] = i + 1;
  }
  for (i = 0; i < n; i = i + 1) {
    swap(a[i], a[getNextX() % (i + 1)]);
  }
  for (i = 0; i < n; i = i + 1) {
    if (i < d)
      b[i] = 1;
    else
      b[i] = 0;
  }
  for (i = 0; i < n; i = i + 1) {
    swap(b[i], b[getNextX() % (i + 1)]);
  }
}
int main(int argc, char* argv[]) {
  cin >> n >> d >> x;
  initAB();
  int pos[LIM];
  vector<int> B;
  int BOUND = 30;
  for (int i = 0; i < n; i++) pos[a[i]] = i;
  for (int i = 0; i < n; i++)
    if (b[i]) B.push_back(i);
  for (int i = 0; i < n; i++) {
    int j;
    for (j = n; j > n - BOUND; j--)
      if (j >= 0 && i >= pos[j] && b[i - pos[j]]) {
        cout << j << "\n";
        break;
      }
    if (j == n - BOUND) {
      long long maxc = 0, c;
      for (int jc = 0; jc < B.size(); jc++)
        if (B[jc] <= i) {
          j = i - B[jc];
          maxc = max(maxc, a[j]);
        }
      cout << maxc << "\n";
    }
  }
  return 0;
}
