#include <bits/stdc++.h>
using namespace std;
int a[100050], b[100050], c[100050], wz[100050], _wz[100050], n, m, p;
inline int GetNew() { return p = (p * 37LL + 10007) % 1000000007; }
void Pretreat() {
  for (int i = 0; i < n; i++) a[i] = i + 1;
  for (int i = 0; i < n; i++) swap(a[i], a[GetNew() % (i + 1)]);
  for (int i = 0; i < n; i++) b[i] = i < m;
  for (int i = 0; i < n; i++) swap(b[i], b[GetNew() % (i + 1)]);
  for (int i = 0; i < n; i++)
    if (b[i]) _wz[++_wz[0]] = i;
  return;
}
int main() {
  cin >> n >> m >> p;
  Pretreat();
  for (int i = 0; i < n; i++) wz[a[i]] = i;
  int s = min(30, n - 1);
  for (int i = 0; i < n; i++) {
    int Ans = false;
    for (int j = n; j >= n - s && !Ans; j--)
      if (wz[j] <= i && b[i - wz[j]]) Ans = j;
    if (!Ans)
      for (int j = 1; j <= _wz[0] && _wz[j] <= i; j++)
        if (b[_wz[j]]) Ans = max(Ans, a[i - _wz[j]]);
    printf("%d\n", Ans);
  }
  return 0;
}
