#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
long long n, d, x, a[maxn], b[maxn], posa[maxn], pos1[maxn], sum;
__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 main() {
  cin >> n >> d >> x;
  initAB();
  for (int i = 0; i < n; i++) {
    posa[a[i]] = i;
    if (b[i]) pos1[++sum] = i;
  }
  if ((long long)d * d <= n)
    for (int i = 0; i < n; i++) {
      int ans = 0;
      for (int j = 1; j <= d; j++)
        if (pos1[j] <= i)
          if (a[i - pos1[j]] > ans) ans = a[i - pos1[j]];
      cout << ans << endl;
    }
  else
    for (int i = 0; i < n; i++) {
      int ans = 0;
      for (int j = n; j >= 1; j--)
        if (posa[j] <= i)
          if (b[i - posa[j]]) {
            ans = j;
            break;
          }
      cout << ans << endl;
    }
  return 0;
}
