#include <bits/stdc++.h>
using namespace std;
const int li = 300;
long long x, n, d;
int a[200000], b[200000], c[200000];
struct T {
  int a;
  int b;
};
bool operator<(T x, T y) { return x.a < y.a; }
set<T> s;
int 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)]);
  }
}
int main() {
  s.clear();
  cin >> n >> d >> x;
  initAB();
  if (d > 300) {
    for (int i = (0); i <= (n - 1); i++) {
      int ans = 0;
      T nw;
      nw.a = a[i];
      nw.b = i;
      s.insert(nw);
      set<T>::iterator t = s.end();
      while (1) {
        if (t == s.begin()) break;
        t--;
        if (b[i - (*t).b] == 1) {
          ans = (*t).a;
          break;
        }
      }
      printf("%d\n", ans);
    }
  } else {
    c[0] = 0;
    for (int i = (0); i <= (n - 1); i++)
      if (b[i]) c[++c[0]] = i;
    for (int i = (0); i <= (n - 1); i++) {
      int ans = 0;
      for (int j = (1); j <= (c[0]); j++)
        if (c[j] > i)
          break;
        else {
          if (a[i - c[j]] > ans) ans = a[i - c[j]];
        }
      printf("%d\n", ans);
    }
  }
}
