#include <bits/stdc++.h>
const int N = 1e5 + 7, Limit = 300;
using namespace std;
int n, d;
long long x;
int a[N], b[N], pos[N];
vector<int> data;
int 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() {
  n = 1;
  cin >> n >> d >> x;
  initAB();
  for (int i = 0; i < n; i++) pos[a[i]] = i;
  for (int i = 0; i < n; ++i)
    if (b[i]) data.push_back(i);
  bool flag;
  int ans;
  for (int i = 0; i < n; ++i) {
    flag = false;
    for (int j = n; j >= n - Limit && j >= 0; --j) {
      if (pos[j] <= i && b[i - pos[j]]) {
        flag = true;
        printf("%d\n", j);
        break;
      }
    }
    if (flag) continue;
    ans = 0;
    for (int j = 0; j < data.size() && data[j] <= i; ++j)
      ans = max(ans, a[i - data[j]]);
    printf("%d\n", ans);
  }
  return 0;
}
