#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') f = -1;
  for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
  return x * f;
}
long long n, d, x, a[200005], b[200005], q[200005];
bool ext[200005];
int 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)]);
  }
}
set<pair<long long, int> > s;
set<pair<long long, int> >::iterator it;
int main() {
  n = read(), d = read(), x = read();
  initAB();
  int R = 0;
  for (int i = 0; i < n; ++i)
    if (b[i]) ext[i] = 1, q[++R] = i;
  for (int i = 0; i < n; ++i) {
    s.insert(pair<long long, int>(-a[i], i));
    it = s.begin();
    bool flag = 0;
    for (int j = 1; j <= 50 && it != s.end(); ++j, it++) {
      if (ext[i - (it->second)]) {
        printf("%d\n", -(it->first));
        flag = 1;
        break;
      }
    }
    if (!flag) {
      long long ans = 0;
      for (int j = 1; j <= R && q[j] <= i; ++j) ans = max(ans, a[i - q[j]]);
      printf("%d\n", ans);
    }
  }
  return 0;
}
