#include <bits/stdc++.h>
using namespace std;
int n, d;
long long x;
const int MAXN = 500000;
int a[MAXN];
int b[MAXN];
int bLis[MAXN], bT;
int c[MAXN];
int loc[MAXN];
long long getNextX() {
  x = (x * 37LL + 10007LL) % 1000000007LL;
  return x;
}
int main() {
  cin >> 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[getNextX() % (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[getNextX() % (i + 1)]);
  }
  for (int i = 0; i < n; ++i) {
    loc[a[i]] = i;
  }
  int bT = 0;
  for (int i = 0; i < n; ++i) {
    if (b[i] == 1) {
      bLis[bT++] = i;
    }
  }
  for (int i = 0; i < n; ++i) {
    c[i] = -1;
  }
  for (int i = n; i >= n - 500 && i >= 1; --i) {
    int p = loc[i];
    for (int j = 0; j < bT && p + bLis[j] < n; ++j) {
      if (c[p + bLis[j]] == -1) {
        c[p + bLis[j]] = i;
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    if (c[i] == -1) {
      c[i] = 0;
      for (int j = 0; j < bT && bLis[j] <= i; ++j) {
        c[i] = max(c[i], a[i - bLis[j]]);
      }
    }
    cout << c[i] << "\n";
  }
}
