#include <bits/stdc++.h>
using namespace std;
long long a[100005], b[100005], b_pos[100005],
    c[100005] =
        {
            0,
},
    x, n, d, pos_a[100005];
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();
  int b_pos_ind = 1;
  for (int i = 0; i < n; i++)
    if (b[i]) b_pos[b_pos_ind++] = i;
  for (int i = 0; i < n; i++) pos_a[a[i]] = i;
  int n2 = n - 1;
  for (int i = n; i > 0; i--) {
    for (int j = 1; j < b_pos_ind; j++) {
      int tm = pos_a[i] + b_pos[j];
      if (tm > n2)
        break;
      else if (c[tm] == 0)
        c[tm] = i;
    }
    while (c[n2]) n2--;
  }
  for (int i = 0; i < n; i++) cout << c[i] << endl;
  return 0;
}
