#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
int n, m, d, x;
int a[111111], b[111111], c[111111];
vector<int> bit;
int pos[111111];
int getNextX() {
  x = (1ll * 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)]);
  }
}
int main() {
  int t, y, z, ca = 1;
  scanf("%d%d%d", &(n), &(d), &(x));
  initAB();
  for (int i = 0; i < (int)(n); ++i) pos[a[i]] = i;
  for (int i = 0; i < (int)(n); ++i)
    if (b[i]) bit.push_back(i);
  for (int i = 0; i < (int)(n); ++i) {
    int find = 0;
    for (int j = n, k = 0; k < min(400, n); ++k, j--) {
      if (pos[j] <= i && b[i - pos[j]] == 1) {
        c[i] = j;
        find = 1;
        break;
      }
    }
    if (!find) {
      int tt = 0;
      for (int j = 0; j < (int)(((int)bit.size())); ++j) {
        if (bit[j] > i)
          break;
        else
          tt = max(a[i - bit[j]], tt);
      }
      c[i] = tt;
    }
  }
  for (int i = 0; i < (int)(n); ++i) printf("%d\n", (c[i]));
  return 0;
}
