#include <bits/stdc++.h>
using namespace std;
long long x, n, d;
int a[111111], b[111111], c[111111], rev[111111];
vector<int> bc;
int getNextX() {
  x = (x * 37 + 10007) % 1000000007;
  return x;
}
void initAB() {
  for (int i = 0; i < n; i++) {
    a[i] = i + 1;
  }
  for (int i = 0; i < n; i++) {
    int j = getNextX() % (i + 1);
    int t = a[i];
    a[i] = a[j];
    a[j] = t;
  }
  for (int i = 0; i < n; i++) {
    if (i < d)
      b[i] = 1;
    else
      b[i] = 0;
  }
  for (int i = 0; i < n; i++) {
    int j = getNextX() % (i + 1);
    int t = b[i];
    b[i] = b[j];
    b[j] = t;
  }
  for (int i = 0; i < n; i++)
    if (b[i] == 1) bc.push_back(i);
}
void bpf(int i) {
  int mx = 0;
  for (unsigned int j = 0; j < bc.size() && bc[j] <= i; j++)
    if (mx < a[i - bc[j]]) mx = a[i - bc[j]];
  c[i] = mx;
}
void bpf1() {
  for (int i = 0; i < n; i++) {
    rev[a[i]] = i;
    c[i] = -1;
  }
  int rn = n - d;
  for (int i = 0; i < n; i++) {
    for (int aa = n; aa > rn; aa--)
      if (i >= rev[aa] && b[i - rev[aa]] == 1) {
        c[i] = aa;
        break;
      }
    if (c[i] == -1) bpf(i);
  }
  for (int i = 0; i < n; i++) cout << c[i] << endl;
}
int main() {
  cin >> n >> d >> x;
  initAB();
  bpf1();
  return 0;
}
