#include <bits/stdc++.h>
using namespace std;
long long x;
int n, d;
struct cmp {
  bool operator()(pair<int, int> x, pair<int, int> y) {
    return x.first > y.first;
  }
};
set<pair<int, int>, cmp> que;
set<pair<int, int>, cmp>::iterator it;
vector<int> num;
int a[100005], c[100005];
bool b[100005];
long long next() {
  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++) swap(a[i], a[next() % (i + 1)]);
  for (int i = 0; i < n; i++) {
    if (i < d)
      b[i] = 1;
    else
      b[i] = 0;
  }
  for (int i = 0; i < n; i++) swap(b[i], b[next() % (i + 1)]);
}
int main() {
  scanf("%d%d%I64d", &n, &d, &x);
  initAB();
  if (d < 1000) {
    for (int i = 0; i < n; i++) {
      if (b[i]) num.push_back(i);
      for (int j = 0; j < num.size(); j++) c[i] = max(c[i], a[i - num[j]]);
    }
  } else {
    for (int i = 0; i < n; i++) {
      que.insert(make_pair(a[i], i));
      for (it = que.begin(); it != que.end(); it++) {
        if (b[i - it->second]) {
          c[i] = it->first;
          break;
        }
      }
    }
  }
  for (int i = 0; i < n; i++) cout << c[i] << endl;
  return 0;
}
