#include <bits/stdc++.h>
using namespace std;
int nextInt() {
  int res;
  assert(cin >> res);
  return res;
}
const int N = (int)1e5;
const int BUBEN = 30;
int pos[N];
int a[N];
int b[N];
int x;
int getNextX() { return x = (x * 37LL + 10007) % 1000000007; }
int main() {
  ios::sync_with_stdio(false);
  int n = nextInt();
  int d = nextInt();
  x = nextInt();
  for (int i = 0; i < n; ++i) a[i] = i;
  for (int i = 0; i < n; ++i) swap(a[i], a[getNextX() % (i + 1)]);
  for (int i = 0; i < n; ++i) b[i] = i < d ? 1 : 0;
  for (int i = 0; i < n; ++i) swap(b[i], b[getNextX() % (i + 1)]);
  vector<int> one;
  for (int i = 0; i < n; ++i) {
    if (b[i] == 1) one.push_back(i);
    pos[a[i]] = i;
  }
  for (int i = 0; i < n; ++i) {
    bool found = false;
    for (int res = n - 1; res >= n - BUBEN && res >= 0; --res)
      if (pos[res] <= i && b[i - pos[res]] == 1) {
        printf("%d\n", res + 1);
        found = true;
        break;
      }
    if (found) continue;
    int res = -1;
    for (int j = 0; j < (int)one.size(); ++j)
      if (one[j] <= i) res = max(res, a[i - one[j]]);
    printf("%d\n", res + 1);
  }
  return 0;
}
