#include <bits/stdc++.h>
using namespace std;
long long x;
int n, d;
vector<int> a, b;
long long getNextX() {
  x = (x * 37 + 10007) % 1000000007;
  return x;
}
void initAB() {
  int i;
  for (i = 0; i < n; i = i + 1) {
    a.push_back(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.push_back(1);
    else
      b.push_back(0);
  }
  for (i = 0; i < n; i = i + 1) {
    swap(b[i], b[getNextX() % (i + 1)]);
  }
}
int main() {
  cin >> n >> d >> x;
  initAB();
  vector<int> b1;
  int i, j;
  if (d < 1000) {
    for (i = 0; i < n; ++i) {
      int c = 0;
      if (b[i]) b1.push_back(i);
      for (j = 0; j < b1.size(); ++j) c = max(c, a[i - b1[j]]);
      cout << c << endl;
    }
  } else {
    map<int, int> ai;
    for (i = 0; i < n; ++i) {
      ai[a[i]] = i;
      auto it = ai.rbegin();
      while (it != ai.rend() && !b[i - it->second]) it++;
      cout << (it == ai.rend() ? 0 : it->first) << endl;
    }
  }
}
