/* Author: goats_9 */
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr int K = 500;
ll nx(ll& x) { return x = (x * 37 + 10007) % 1000000007; }
int main() {
cin.tie(0)->sync_with_stdio(0);
int n, d;
ll x;
cin >> n >> d >> x;
vector<int> a(n), b(n), c(n + 1), r(n);
iota(a.begin(), a.end(), 1);
for (int i = 0; i < d; i++) b[i] = 1;
for (int i = 0; i < n; i++) swap(a[i], a[nx(x) % (i + 1)]);
for (int i = 0; i < n; i++) swap(b[i], b[nx(x) % (i + 1)]);
vector<int> id;
for (int i = 0; i < n; i++) if (b[i]) id.push_back(i);
for (int i = 0; i < n; i++) c[a[i]] = i;
set<int> st;
for (int i = 0; i < n; i++) st.insert(i);
for (int i = n; i; i--) {
if (st.size() >= K) {
for (int y : id) {
int j = c[i] + y;
if (j >= n) break;
if (r[j]) continue;
r[j] = i;
st.erase(j);
}
} else {
vector<int> rm;
for (int u : st) {
if (u < c[i] || !b[u - c[i]]) continue;
rm.push_back(u);
r[u] = i;
}
for (auto u : rm) st.erase(u);
}
}
for (auto z : r) cout << z << '\n';
return 0;
}