#include <bits/stdc++.h>
using namespace std;
const int LOG = 6;
const int DIV = 1 << LOG;
const int DIVM1 = DIV - 1;
class MBitSet {
 public:
  unsigned long long *vals;
  int n;
  MBitSet(const vector<int> &a, int shift) {
    n = 1 + (int)a.size() / DIV + 1;
    vals = new unsigned long long[n];
    fill(vals, vals + n, 0);
    for (int i = 0; i < (int)a.size(); i++)
      if (a[i] == 1) {
        int pos = i + shift;
        vals[pos >> LOG] |= 1LL << (pos & DIVM1);
      }
  }
  MBitSet(int n) {
    this->n = 1 + n / DIV + 1;
    vals = new unsigned long long[this->n];
    fill(vals, vals + this->n, 0);
  }
  ~MBitSet() { delete[] vals; }
  void set(int pos) { vals[pos >> LOG] ^= 1LL << (pos & DIVM1); }
};
long long x;
int next() {
  x = (x * 37 + 10007) % 1000000007;
  return (int)x;
}
void shuffle(vector<int> &a) {
  for (int i = 0; i < (int)a.size(); i++) {
    int index = next() % (i + 1);
    swap(a[i], a[index]);
  }
}
int NumberOfTrailingZeros(long long x) {
  for (int cnt = 0; x != 0; x >>= 1, ++cnt) {
    if (x & 1) return cnt;
  }
  throw int();
}
int main() {
  ios_base::sync_with_stdio(false);
  int n, d;
  cin >> n >> d >> x;
  vector<int> c(n), a(n), b(n);
  for (int _n(n), i(0); i < _n; i++) a[i] = i + 1;
  fill(b.begin(), b.begin() + d, 1);
  shuffle(a);
  shuffle(b);
  vector<int> pos(n);
  for (int i = 0; i < n; i++) {
    pos[a[i] - 1] = i;
  }
  vector<unique_ptr<MBitSet> > bs(DIV);
  for (int i = 0; i < DIV; i++) bs[i].reset(new MBitSet(b, i));
  unique_ptr<MBitSet> curNotSet;
  curNotSet.reset(new MBitSet(n));
  for (int i = 0; i < n; i++) curNotSet->set(i);
  for (int i = n - 1; i >= 0; i--) {
    int p = pos[i];
    int start = p / DIV;
    int xx = p & DIVM1;
    for (int j = start; j < curNotSet->n; j++) {
      unsigned long long tt = curNotSet->vals[j] & bs[xx]->vals[j - start];
      for (int v = 0; tt != 0; ++v) {
        if (tt & 1) {
          int posit = j * DIV + v;
          c[posit] = i + 1;
          curNotSet->set(posit);
        }
        tt >>= 1;
      }
    }
  }
  for (int v : c) cout << v << endl;
  return 0;
}
