#include <cstdio>
#include <algorithm>
#include <cmath>
#include <ctime>
using namespace std;
int n, d, X, A[110000], B[110000], q[110000], to[110000];
int pu;
int getNextX() {
X = (X * 37LL + 10007) % 1000000007;
return X;
}
int main() {
scanf("%d%d%d", &n, &d, &X);
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)]);
for (int i = 0; i < n; i++) if (B[i]) q[++q[0]] = i;
int s = 30;
for (int i = 0; i < n; i++) to[A[i]] = i;
for (int i = 0; i < n; i++) {
int j;
for (j = n; j >= n - s; j--)
if (j > 0 && i >= to[j] && B[i - to[j]]) {
printf("%d\n", j);
break;
}
if (j < n - s) {
int ma = 0;
for (j = 1; j <= q[0] && q[j] <= i; j++)
ma = max(ma, A[i - q[j]]);
printf("%d\n", ma);
}
}
}
I2luY2x1ZGUgPGNzdGRpbz4KI2luY2x1ZGUgPGFsZ29yaXRobT4KI2luY2x1ZGUgPGNtYXRoPgojaW5jbHVkZSA8Y3RpbWU+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgbiwgZCwgWCwgQVsxMTAwMDBdLCBCWzExMDAwMF0sIHFbMTEwMDAwXSwgdG9bMTEwMDAwXTsKaW50IHB1OwoKaW50IGdldE5leHRYKCkgewoJWCA9IChYICogMzdMTCArIDEwMDA3KSAlIDEwMDAwMDAwMDc7CiAgICByZXR1cm4gWDsKfQoKaW50IG1haW4oKSB7CglzY2FuZigiJWQlZCVkIiwgJm4sICZkLCAmWCk7CiAgICBmb3IgKGludCBpID0gMDsgaSA8IG47IGkgPSBpICsgMSkKICAgICAgICBBW2ldID0gaSArIDE7CiAgICBmb3IgKGludCBpID0gMDsgaSA8IG47IGkgPSBpICsgMSkKICAgICAgICBzd2FwKEFbaV0sIE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