#include <bits/stdc++.h>
using namespace std;
long long x;
int n, d;
int a[100000], b[100000];
priority_queue<pair<int, int> > q;
pair<int, int> v[100002];
int vs;
vector<int> c;
int getNextX() {
  x = (x * 37 + 10007) % 1000000007;
  return (int)x;
}
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();
  if ((long long)d * d < n * 36) {
    for (int i = 0; i < (int)(n); i++)
      if (b[i] == 1) c.push_back(i);
    for (int i = 0; i < (int)(n); i++) {
      int ans = 0;
      int l = -1, r = c.size() - 1, mid;
      while (l < r) {
        mid = (l + r + 1) >> 1;
        if (i < c[mid])
          r = mid - 1;
        else
          l = mid;
      }
      int f = l;
      for (int j = 0; j <= f; ++j) ans = max(ans, a[i - c[j]]);
      printf("%d\n", ans);
    }
    return 0;
  }
  for (int i = 0; i < (int)(n); i++) {
    q.push(make_pair(a[i], i));
    vs = 0;
    int ans = 0;
    while (!q.empty()) {
      int z = q.top().second;
      if (b[i - z] == 0) {
        v[vs++] = q.top();
        q.pop();
      } else {
        ans = a[z];
        break;
      }
    }
    for (int j = 0; j < (int)(vs); j++) q.push(v[j]);
    printf("%d\n", ans);
  }
  return 0;
}
