#include <bits/stdc++.h>
using namespace std;
long long nx(long long &x) {
  x = (x * 37 + 10007) % 1000000007;
  return x;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie();
  cout.tie();
  long long n, d, x;
  cin >> n >> d >> x;
  vector<long long> a(n), b(n);
  iota(a.begin(), a.end(), 1);
  for (long long i = 0; i < n; i++) {
    swap(a[i], a[nx(x) % (i + 1)]);
  }
  for (long long i = 0; i < n; i++) {
    b[i] = (long long)(i < d);
  }
  for (long long i = 0; i < n; i++) {
    swap(b[i], b[nx(x) % (i + 1)]);
  }
  if (d * d < n) {
    set<long long> _b;
    for (long long i = 0; i < n; i++) {
      if (b[i]) _b.insert(i);
      long long res = 0;
      for (auto j : _b) {
        res = max(res, a[i - j]);
      }
      cout << res << '\n';
    }
  } else {
    set<pair<long long, long long> > _a;
    for (long long i = 0; i < n; i++) {
      _a.insert({-a[i], i});
      long long res = 0;
      for (auto j : _a) {
        long long value = -j.first, pos = j.second;
        if (b[i - pos]) {
          res = value;
          break;
        }
      }
      cout << res << '\n';
    }
  }
  return 0;
}
