#include <bits/stdc++.h>
using namespace std;
static long long x;
static int d;
static int n;
long long getNextX() {
  x = (x * 37 + 10007) % 1000000007;
  return x;
}
void init(vector<int>& a, vector<int>& b) {
  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) b[i] = (i < d);
  for (int i = 0; i < n; ++i) swap(b[i], b[getNextX() % (i + 1)]);
}
void print(vector<int>& a) {
  for (size_t i = 0; i < a.size(); ++i) printf("%d\n", a[i]);
}
int main() {
  cin >> n >> d >> x;
  vector<int> a(n);
  vector<int> b(n);
  vector<int> ind(n);
  vector<int> c(n, 0);
  init(a, b);
  set<pair<int, int> > s;
  if (d < sqrt(n)) {
    vector<int> v;
    v.clear();
    for (int i = 0; i < n; ++i) {
      if (b[i]) v.push_back(i);
      for (size_t j = 0; j < v.size(); ++j) c[i] = max(c[i], a[i - v[j]]);
    }
  } else {
    for (size_t i = 0; i < c.size(); ++i) {
      s.insert(make_pair(a[i], i));
      for (auto rit = s.rbegin(); rit != s.rend(); ++rit) {
        if (b[i - rit->second]) {
          c[i] = rit->first;
          break;
        }
      }
    }
  }
  print(c);
  return 0;
}
