#include <bits/stdc++.h>
using namespace std;
const int INF = 2147483647;
const long long LLINF = 9223372036854775807LL;
const int maxn = 100010;
const int MAGIC = 800;
int a[maxn];
int b[maxn];
int ans[maxn];
vector<int> ds;
long long x;
int n, d;
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 main() {
  cin >> n >> d >> x;
  initAB();
  if (d < MAGIC) {
    for (int i = 0; i < n; ++i)
      if (b[i]) ds.push_back(i);
    for (int i = 0; i < n; ++i) {
      for (int jj = 0; jj < int((ds).size()); ++jj) {
        int j = ds[jj];
        if (i + j >= n) break;
        if (b[j]) ans[i + j] = max(ans[i + j], a[i]);
      }
    }
  } else {
    vector<pair<int, int> > order;
    for (int i = 0; i < n; ++i) order.push_back(make_pair(a[i], i));
    sort(order.begin(), order.end());
    priority_queue<int> q;
    for (int i = 0; i < n; ++i) {
      if (ans[i] == 0) {
        q.push(a[i]);
        vector<int> tmp;
        while (int((q).size())) {
          int cur = q.top();
          q.pop();
          tmp.push_back(cur);
          int j = order[cur - 1].second;
          if (i - j >= 0 && b[i - j]) {
            ans[i] = cur;
            break;
          }
        }
        for (int j = 0; j < int((tmp).size()); ++j) q.push(tmp[j]);
      }
    }
  }
  for (int i = 0; i < n; ++i) printf("%d\n", ans[i]);
  return 0;
}
