#include <bits/stdc++.h>
using namespace std;
long long x;
int n, d;
set<int> s;
int a[100005], b[100005], st[100005], top;
inline long long getNextX() {
  x = (x * 37 + 10007) % 1000000007;
  return x;
}
inline 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 p[100005];
bool cmp(const int &i, const int &j) { return a[i] > a[j]; }
int main() {
  scanf("%d%d%I64d", &n, &d, &x);
  initAB();
  for (int i = 0; i < n; ++i) p[a[i]] = i;
  for (int i = 0; i < n; ++i) {
    if (b[i]) st[top++] = i;
    int ans = 0;
    s.insert(-a[i]);
    if (top < 400) {
      for (int j = 0; j < top; ++j)
        if (a[i - st[j]] > ans) ans = a[i - st[j]];
    } else {
      for (set<int>::iterator it = s.begin(); it != s.end(); ++it)
        if (b[i - p[-(*it)]]) {
          ans = -(*it);
          break;
        }
    }
    printf("%d\n", ans);
  }
  return 0;
}
