#include <bits/stdc++.h>
using namespace std;
const long long inf = 2e18 + 7;
const long long mod = 1e9 + 7;
const double eps = 1e-12;
const double PI = 2 * acos(0.0);
const double E = 2.71828;
int n, d, X;
int nxt() {
  X = (1LL * X * 37 + 10007) % 1000000007;
  return X;
}
int a[100005], b[100005];
int pos[100005];
int res[100005];
set<int> x, y;
int main(void) {
  scanf("%d %d %d", &n, &d, &X);
  for (int(i) = 0; (i) < (n); ++(i)) {
    a[i] = i + 1;
  }
  for (int(i) = 0; (i) < (n); ++(i)) {
    swap(a[i], a[nxt() % (i + 1)]);
  }
  for (int(i) = 0; (i) < (n); ++(i)) {
    if (i < d)
      b[i] = 1;
    else
      b[i] = 0;
  }
  for (int(i) = 0; (i) < (n); ++(i)) {
    swap(b[i], b[nxt() % (i + 1)]);
  }
  for (int(i) = 0; (i) < (n); ++(i)) x.insert(i);
  for (int(i) = 0; (i) < (n); ++(i))
    if (b[i]) y.insert(i);
  for (int(i) = 0; (i) < (n); ++(i)) {
    pos[a[i]] = i;
  }
  for (int i = n; i >= 1; --i) {
    int it = pos[i];
    set<int>::iterator first = x.lower_bound(it);
    set<int>::iterator second = y.begin();
    for (; first != x.end();) {
      int cur = *first;
      second = y.lower_bound(cur - it);
      if (second == y.end()) {
        break;
      }
      if (*second == cur - it) {
        res[cur] = i;
        x.erase(first);
      }
      first = x.lower_bound(it + *second);
    }
  }
  for (int(i) = 0; (i) < (n); ++(i)) printf("%d\n", res[i]);
  return 0;
}
