#include <bits/stdc++.h>
using namespace std;
int dx[] = {0, 0, 1, -1, 1, -1, 1, -1}, dy[] = {-1, 1, 0, 0, 1, -1, -1, 1};
const int mod = 1e9 + 7;
int n, d;
unsigned long long x;
int *a = new int[100000], *b = new int[100000];
int apos[100001], bpos[100000];
unsigned 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() {
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(16);
  cin >> n >> d >> x;
  initAB();
  if (d > 1000) {
    for (int i = (0); i < (n); ++i) apos[a[i]] = i;
    for (int i = (0); i < (n); ++i) {
      for (int v = n; v >= 1; v--)
        if (apos[v] <= i && b[i - apos[v]]) {
          cout << v << "\n";
          goto found;
        }
      cout << 0 << "\n";
    found:;
    }
  } else {
    int bs = 0;
    for (int i = (0); i < (n); ++i)
      if (b[i]) bpos[bs++] = i;
    for (int i = (0); i < (n); ++i) {
      int c = 0;
      for (int j = 0; j < d && bpos[j] <= i; j++) c = max(c, a[i - bpos[j]]);
      cout << c << "\n";
    }
  }
}
