#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline T ABS(T a) {
  return a > 0 ? a : -a;
}
template <typename T>
inline T MIN(T a, T b) {
  return a < b ? a : b;
}
template <typename T>
inline T MAX(T a, T b) {
  return a > b ? a : b;
}
template <typename T>
inline T CHKMIN(T &a, T b) {
  if (a > b) a = b;
  return a;
}
template <typename T>
inline T CHKMAX(T &a, T b) {
  if (a < b) a = b;
  return a;
}
template <typename T>
inline void SWAP(T &a, T &b) {
  static T c;
  c = a;
  a = b;
  b = c;
}
typedef int (*CMP)(const void *, const void *);
template <typename T>
int ltcmp(const T *a, const T *b) {
  if (*a != *b) return *a < *b ? -1 : 1;
  return 0;
}
template <typename T, unsigned int n>
int ltcmp(const T a[], const T b[]) {
  for (int i = (0); i < (int)(n); ++i)
    if (a[i] != b[i]) return a[i] < b[i] ? -1 : 1;
  return 0;
}
template <typename T>
int gtcmp(const T *a, const T *b) {
  if (*a != *b) return *a > *b ? -1 : 1;
  return 0;
}
template <typename T, unsigned int n>
int gtcmp(const T a[], const T b[]) {
  for (int i = (0); i < (int)(n); ++i)
    if (a[i] != b[i]) return a[i] > b[i] ? -1 : 1;
  return 0;
}
template <typename T, typename... T0>
T MAX(T a, T b, T0... c) {
  return a > b ? MAX(a, c...) : MAX(b, c...);
}
template <typename T, typename... T0>
T MIN(T a, T b, T0... c) {
  return a < b ? MIN(a, c...) : MIN(b, c...);
}
long long x;
int n, d, a[200000], b[200000];
long long getNextX() {
  x = (x * 37LL + 10007LL) % 1000000007LL;
  return x;
}
void initAB() {
  int i;
  for (i = 0; i < n; i = i + 1) {
    a[i] = i + 1;
  }
  for (i = 0; i < n; i = i + 1) {
    swap(a[i], a[getNextX() % (i + 1)]);
  }
  for (i = 0; i < n; i = i + 1) {
    if (i < d)
      b[i] = 1;
    else
      b[i] = 0;
  }
  for (i = 0; i < n; i = i + 1) {
    swap(b[i], b[getNextX() % (i + 1)]);
  }
}
int r[200000], q[200000], top;
int main() {
  int ans;
  while (cin >> n >> d >> x) {
    initAB();
    top = 0;
    for (int i = (0); i < (int)(n); ++i) r[a[i] - 1] = i;
    for (int i = (0); i < (int)(n); ++i) {
      if (b[i]) q[top++] = i;
    }
    for (int k = (0); k < (int)(n); ++k) {
      for (int i = (0); i < (int)(30); ++i) {
        int tmp = r[n - 1 - i];
        if (i > n) break;
        if (tmp > k || b[k - tmp] == 0)
          continue;
        else {
          printf("%d\n", n - i);
          goto end;
        }
      }
      ans = 0;
      for (int i = (0); i < (int)(top); ++i) {
        if (q[i] > k) break;
        CHKMAX(ans, a[k - q[i]]);
      }
      printf("%d\n", ans);
    end:;
    }
  }
  return 0;
}
