#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10, mod = 1e9 + 7;
int a[maxn], b[maxn], c[maxn], vis[maxn], cur[maxn], x, d, n;
int getNextX() {
  x = (1ll * 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)]);
  }
}
struct node {
  int v, id;
  node(int x, int y) { v = x, id = y; }
  bool operator<(const node& t) const { return v < t.v; }
};
priority_queue<node> q;
int main() {
  scanf("%d%d%d", &n, &d, &x);
  initAB();
  int cnt = 0;
  for (int i = 0; i < n; i++)
    if (b[i]) cur[cnt++] = i;
  for (int i = 0; i < n; i++) q.push(node(a[i], i));
  for (int i = 0; i < min(70, n); i++) {
    node e = q.top();
    q.pop();
    for (int j = 0; j < cnt; j++)
      if (e.id + cur[j] < n && !vis[e.id + cur[j]]) {
        vis[e.id + cur[j]] = 1;
        c[e.id + cur[j]] = e.v;
      }
  }
  for (int i = 0; i < n; i++)
    if (!vis[i]) {
      for (int j = 0; j < cnt && cur[j] <= i; j++)
        c[i] = max(c[i], a[i - cur[j]]);
    }
  for (int i = 0; i < n; i++) printf("%d\n", c[i]);
}
