#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const double eps = 1e-9;
const int INF = inf;
const double EPS = eps;
struct __timestamper {};
long long curX;
long long getNextX() {
  curX = (curX * 37 + 10007) % 1000000007;
  return curX;
}
int d;
vector<int> as, bs;
void initAB() {
  int i;
  for (i = 0; i < ((int)(as).size()); i = i + 1) {
    as[i] = i + 1;
  }
  for (i = 0; i < ((int)(as).size()); i = i + 1) {
    swap(as[i], as[getNextX() % (i + 1)]);
  }
  for (i = 0; i < ((int)(bs).size()); i = i + 1) {
    bs[i] = (i < d);
  }
  for (i = 0; i < ((int)(bs).size()); i = i + 1) {
    swap(bs[i], bs[getNextX() % (i + 1)]);
  }
}
const int PCSZ = 22;
const int PCMSK = (1 << PCSZ) - 1;
char PCCTZ[1 << PCSZ];
inline int myctz(unsigned long long x) {
  if (x & PCMSK) return PCCTZ[x & PCMSK];
  x >>= PCSZ;
  if (x & PCMSK) return PCCTZ[x & PCMSK] + PCSZ;
  x >>= PCSZ;
  assert(x);
  return PCCTZ[x] + PCSZ + PCSZ;
}
const int MAXN = int(1e5) + 100;
class mbs {
  static const int SZ = (MAXN + 63) / 64;
  unsigned long long data[SZ];

 public:
  mbs() { clear(); }
  void clear() { memset(data, 0, sizeof data); }
  void set(int x) { data[x >> 6] |= 1ULL << (x & 63); }
  void reset(int x) { data[x >> 6] &= ~(1ULL << (x & 63)); }
  void assignAndShift(const mbs &b2, int shift) {
    {
      int tmp = shift / 64;
      for (int i = SZ - 1; i >= tmp; i--) {
        data[i] = b2.data[i - tmp];
      }
      for (int i = tmp - 1; i >= 0; i--) {
        data[i] = 0;
      }
      shift -= tmp * 64;
    }
    if (!shift) return;
    assert(0 < shift && shift < 64);
    for (int i = SZ - 1; i >= 0; i--) {
      data[i] <<= shift;
      if (i > 0) {
        data[i] |= (data[i - 1] >> (64 - shift));
      }
    }
  }
  void getBitsAnd(const mbs &b2, vector<int> &out) {
    out.clear();
    for (int i = 0; i < (SZ); i++) {
      unsigned long long x = data[i] & b2.data[i];
      while (x) {
        int id = myctz(x);
        out.push_back(64 * i + id);
        x ^= 1ULL << id;
      }
    }
  }
};
int main() {
  for (int i = 1; i < (1 << PCSZ); i++) {
    PCCTZ[i] = (i & 1) ? 0 : (PCCTZ[i >> 1] + 1);
  }
  int n;
  while (scanf("%d%d"
               "%lld",
               &n, &d, &curX) == 3) {
    as = vector<int>(n);
    bs = vector<int>(n);
    initAB();
    static mbs unk, msk;
    for (int i = 0; i < (n); i++) {
      unk.set(i);
      if (bs[i]) msk.set(i);
    }
    vector<int> res(n, 0);
    vector<int> poses(n + 1, -1);
    for (int i = 0; i < (n); i++) poses[as[i]] = i;
    for (int val = n; val >= 1; val--) {
      static mbs tmp;
      tmp.assignAndShift(msk, poses[val]);
      static vector<int> bits;
      tmp.getBitsAnd(unk, bits);
      for (int x : bits) {
        res[x] = val;
        unk.reset(x);
      }
    }
    for (int i = 0; i < (n); i++) {
      assert(res[i] >= 0);
      printf("%d\n", res[i]);
    }
  }
  return 0;
}
