#include <bits/stdc++.h>
using namespace std;
int a[100005], pos[100005], ans[100005];
bool b[100005];
int main() {
  int n, d, i, tmp, val, p, j;
  long long x;
  scanf("%d%d%I64d", &n, &d, &x);
  for (i = 0; i < n; i++) a[i] = i + 1;
  for (i = 0; i < n; i++) {
    x = (x * 37 + 10007) % 1000000007;
    tmp = a[i];
    a[i] = a[x % (i + 1)];
    a[x % (i + 1)] = tmp;
  }
  for (i = 0; i < n; i++) {
    if (i < d)
      b[i] = 1;
    else
      b[i] = 0;
  }
  for (i = 0; i < n; i++) {
    x = (x * 37 + 10007) % 1000000007;
    tmp = b[i];
    b[i] = b[x % (i + 1)];
    b[x % (i + 1)] = tmp;
  }
  if (d >= 316) {
    for (i = 0; i < n; i++) pos[a[i]] = n - 1 - i;
    list<int> lst;
    list<int>::iterator it;
    for (i = n; i >= 1; i--) lst.push_back(i);
    for (i = n - 1; i >= 0; i--) {
      it = lst.begin();
      while (it != lst.end()) {
        val = *it;
        p = pos[val] - (n - 1 - i);
        if (p < 0)
          it = lst.erase(it);
        else if (b[p]) {
          ans[i] = val;
          break;
        } else
          it++;
      }
    }
  } else {
    vector<int> one;
    for (i = 0; i < n; i++) {
      if (b[i]) one.push_back(i);
    }
    for (i = n - 1; i >= 0; i--) {
      ans[i] = 0;
      for (j = 0; j < d; j++) ans[i] = max(ans[i], a[i - one[j]]);
    }
  }
  for (i = 0; i < n; i++) printf("%d\n", ans[i]);
  return 0;
}
