#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void umax(T &a, T b) {
  if (a < b) a = b;
}
template <class T>
inline void umin(T &a, T b) {
  if (a > b) a = b;
}
template <class T>
inline T abs(T a) {
  return a > 0 ? a : -a;
}
template <class T>
inline T gcd(T a, T b) {
  return __gcd(a, b);
}
template <class T>
inline T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
const int inf = 1e9 + 143;
const long long longinf = 1e18 + 143;
inline int read() {
  int x;
  scanf(" %d", &x);
  return x;
}
const int N = 101001;
int n, d;
int a[N], b[N];
long long x;
int getNextX() {
  x = (x * 37 + 10007) % 1000000007;
  return x;
}
void initAB() {
  for (int i = 0; i < n; i = i + 1) {
    a[i] = i + 1;
  }
  for (int i = 0; i < n; i = i + 1) {
    swap(a[i], a[getNextX() % (i + 1)]);
  }
  for (int i = 0; i < n; i = i + 1) {
    if (i < d)
      b[i] = 1;
    else
      b[i] = 0;
  }
  for (int i = 0; i < n; i = i + 1) {
    swap(b[i], b[getNextX() % (i + 1)]);
  }
}
int main() {
  n = read();
  d = read();
  x = read();
  initAB();
  if (d <= 1000) {
    vector<int> locs;
    for (int i = 0; i < n; i++)
      if (b[i]) locs.push_back(i);
    for (int i = 0; i < n; i++) {
      int ans = 0;
      for (int j : locs)
        if (i - j >= 0 && i - j <= i) umax(ans, a[i - j]);
      printf("%d\n", ans);
    }
  } else {
    set<pair<int, int> > s;
    for (int i = 0; i < n; i++) {
      s.insert(make_pair(a[i], i));
      int ans = 0;
      for (auto it = s.rbegin(); it != s.rend(); it++)
        if (b[i - it->second]) {
          ans = it->first;
          break;
        }
      printf("%d\n", ans);
    }
  }
  return 0;
}
