#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100000 + 10;
int n, d, a[MAXN], b[MAXN], e[MAXN];
long long first;
vector<int> c;
set<pair<int, int> > s;
long long getNextX() {
  first = (first * 37 + 10007) % 1000000007;
  return first;
}
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)]);
  }
}
int main() {
  cin >> n >> d >> first;
  initAB();
  for (int i = 0; i < n; ++i) {
    int L = (int)(sqrt((double)i) * 2);
    if (b[i]) c.push_back(i);
    s.insert(make_pair(a[i], i));
    if ((int)c.size() <= L) {
      for (int j = 0; j < (int)c.size(); ++j) e[i] = max(e[i], a[i - c[j]]);
    } else {
      for (set<pair<int, int> >::reverse_iterator it = s.rbegin();
           it != s.rend(); ++it)
        if (b[i - it->second]) {
          e[i] = it->first;
          break;
        }
    }
    printf("%d\n", e[i]);
  }
  fclose(stdin);
  fclose(stdout);
  return 0;
}
