#include <bits/stdc++.h>
using namespace std;
const int inf = 2000000000;
static inline int Rint() {
  struct X {
    int dig[256];
    X() {
      for (int i = '0'; i <= '9'; ++i) dig[i] = 1;
      dig['-'] = 1;
    }
  };
  static X fuck;
  int s = 1, v = 0, c;
  for (; !fuck.dig[c = getchar()];)
    ;
  if (c == '-')
    s = 0;
  else if (fuck.dig[c])
    v = c ^ 48;
  for (; fuck.dig[c = getchar()]; v = v * 10 + (c ^ 48))
    ;
  return s ? v : -v;
}
template <typename T>
static inline void cmax(T& a, const T& b) {
  if (b > a) a = b;
}
template <typename T>
static inline void cmin(T& a, const T& b) {
  if (b < a) a = b;
}
const int maxn = 100005;
long long x;
long long a[100005];
long long b[100005];
int n, d;
long long getNextX() {
  x = (x * 37 + 10007) % 1000000007;
  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 ans[maxn];
int where[maxn];
int all_one[maxn];
int main() {
  n = Rint(), d = Rint(), x = Rint();
  initAB();
  for (int i = 0; i < n; ++i) where[a[i]] = i;
  int top = 0;
  for (int i = 0; i < n; ++i)
    if (b[i] == 1) all_one[top++] = i;
  int check = n - 30;
  if (check <= 0) check = 1;
  for (int i = 0; i < n; ++i) {
    int val = -1;
    for (int j = n; j >= check; --j) {
      int pos = where[j];
      if (pos <= i && b[i - pos]) {
        val = j;
        break;
      }
    }
    if (val != -1) {
      ans[i] = val;
      continue;
    }
    int best = 0;
    for (int j = 0; j < top && all_one[j] <= i; ++j) {
      int f = a[i - all_one[j]];
      if (f > best) best = f;
    }
    ans[i] = best;
  }
  for (int i = 0; i < n; ++i) printf("%d\n", ans[i]);
  return 0;
}
