#include <bits/stdc++.h>
using namespace std;
long long n, d, x;
long long a[100100];
long long b[100100];
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 res[100100];
int z[100100];
set<int> st;
set<int> st1;
set<int>::iterator it;
set<int>::iterator it1;
int main() {
  cin >> n >> d >> x;
  initAB();
  for (int i = 0; i < n; i++) {
    z[a[i]] = i;
    if (b[i]) st.insert(n - 1 - i);
    st1.insert(i);
  }
  for (int i = n; i >= 1; i--) {
    int ind = z[i];
    it = st.lower_bound(ind);
    if (it == st.end()) continue;
    it1 = st1.lower_bound(*it - ind);
    while (it != st.end() && it1 != st1.end()) {
      int t = *it1;
      if (st.count(t + ind)) {
        res[*it1] = i;
        st1.erase(it1);
      }
      t += ind;
      it = st.lower_bound(t);
      if (it == st.end()) break;
      it1 = st1.lower_bound(*it - ind);
    }
  }
  for (int i = n - 1; i >= 0; i--) {
    printf("%d\n", res[i]);
  }
  return 0;
}
