#include <bits/stdc++.h>
using namespace std;
long long x;
int n, d;
int a[100005], b[100005], c[100005], pos[100005], sel[100005];
long long getNextX() {
  x = (x * 37 + 10007) % 1000000007;
  return 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)]);
  }
  for (int i = 0; i < n; i++)
    if (b[i]) sel[++sel[0]] = i;
}
int main() {
  cin >> n >> d >> x;
  initAB();
  for (int i = 0; i < n; i++) pos[a[i]] = i;
  for (int i = n, cnt = 0; i >= 1 && cnt <= 20000000; i--) {
    for (int j = 1; j <= sel[0]; j++, cnt++)
      if (pos[i] + sel[j] < n) c[pos[i] + sel[j]] = max(c[pos[i] + sel[j]], i);
  }
  for (int i = 0; i < n; i++)
    if (c[i] == 0) {
      for (int j = 1; j <= sel[0]; j++)
        if (i < sel[j])
          break;
        else
          c[i] = max(c[i], a[i - sel[j]]);
    }
  for (int i = 0; i < n; i++) printf("%d\n", c[i]);
}
