#include <bits/stdc++.h>
using namespace std;
const double EPS = 0.0000001;
const double PI = acos(-1);
const long long INFLL = 0x7FFFFFFFFFFFFFFF;
const int INF = 0x7FFFFFFF;
template <typename T>
inline void next(T &num) {
  char c;
  num = 0;
  do {
    c = getchar_unlocked();
  } while (c != EOF && c == ' ' && c == '\n' && c == '\t');
  int sign = (c == '-' ? -1 : 1);
  if (c != '-') num += (c - '0');
  while ((c = getchar_unlocked()) != EOF && c != '\n' && c != '\t' &&
         c != ' ') {
    num *= 10;
    num += (c - '0');
  }
  num *= sign;
}
inline string getstr() {
  string str;
  char k;
  while ((k = getchar_unlocked()) == ' ' || k == '\n') {
    k = getchar_unlocked();
    if (k == ' ' || k == '\n')
      continue;
    else
      break;
  }
  str.push_back(k);
  while ((k = getchar_unlocked()) != EOF && k != '\n' && k != '\t' &&
         k != '\v' && k != '\0' && k != ' ')
    str.push_back(k);
  return str;
}
const int N = 100005;
int n, d, a[N], b[N], idx[N];
vector<int> on;
long long x;
long long getNextX() {
  x = (x * 37 + 10007) % 1000000007;
  return x;
}
void initAB() {
  for (int i = int(0), _b = int(n - 1); i <= _b; i++) a[i] = i + 1;
  for (int i = int(0), _b = int(n - 1); i <= _b; i++)
    swap(a[i], a[getNextX() % (i + 1)]);
  for (int i = int(0), _b = int(n - 1); i <= _b; i++) b[i] = (i < d);
  for (int i = int(0), _b = int(n - 1); i <= _b; i++)
    swap(b[i], b[getNextX() % (i + 1)]);
}
int main() {
  scanf("%d%d%I64d", &n, &d, &x);
  initAB();
  for (int i = int(0), _b = int(n - 1); i <= _b; i++) idx[a[i]] = i;
  for (int i = int(0), _b = int(n - 1); i <= _b; i++) {
    int ans = 0;
    if (b[i]) on.push_back(i);
    if (on.size() > 330) {
      for (int cur = int(n), _b = int(1); cur >= _b; cur--)
        if (idx[cur] <= i && b[i - idx[cur]]) {
          ans = cur;
          break;
        }
    } else
      for (__typeof(on.begin()) cur = on.begin(); cur != on.end(); cur++)
        ans = max(ans, a[i - *cur]);
    printf("%d\n", ans);
  }
  return 0;
}
