#include <bits/stdc++.h>
using namespace std;
void showVector(vector<long long> s) {
  cout << "----------" << endl;
  for (auto x : s) cout << x << " ";
  cout << endl << "----------" << endl;
}
void prllln(long long n, long long s1 = 0, long long s2 = 0, long long s3 = 0) {
  if (n == 1)
    cout << s1;
  else if (n == 2)
    cout << s1 << " " << s2;
  else
    cout << s1 << " " << s2 << " " << s3;
  cout << endl;
}
const long long MAX_V = 11;
long long head[MAX_V];
struct EDGE {
  long long u, v, w;
  EDGE(long long tu = 0, long long tv = 0, long long tw = 0) {
    u = tu, v = tv, w = tw;
  }
};
struct Triple {
  long long f, s, t;
};
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long n, d, x;
long long a[1111111];
long long b[1111111];
long long c[1111111];
long long idx[11111111];
long long getNextX() {
  x = (x * 37 + 10007) % 1000000007;
  return x;
}
void initAB() {
  for (long long i = 0; i < n; i++) {
    a[i] = i + 1;
  }
  for (long long i = 0; i < n; i++) {
    swap(a[i], a[getNextX() % (i + 1)]);
  }
  for (long long i = 0; i < n; i = i + 1) {
    if (i < d)
      b[i] = 1;
    else
      b[i] = 0;
  }
  for (long long i = 0; i < n; i++) {
    swap(b[i], b[getNextX() % (i + 1)]);
  }
}
long long q[1111111];
int main() {
  cin >> n >> d >> x;
  initAB();
  for (long long i = 0; i < n; i++) {
    if (b[i]) {
      q[++q[0]] = i;
    }
  }
  for (long long i = 0; i < n; i++) idx[a[i]] = i;
  long long s = 30;
  for (long long i = 0; i < n; i++) {
    bool found = false;
    for (long long j = n; j >= n - s; j--) {
      long long ori_idx = idx[j];
      if (ori_idx <= i) {
        if (b[i - ori_idx]) {
          cout << j << endl;
          found = true;
          break;
        }
      }
    }
    long long maxn = 0;
    if (!found) {
      for (int j = 1; j <= q[0] && q[j] <= i; j++) {
        int nowidx_in_b = q[j];
        maxn = max(maxn, a[i - nowidx_in_b]);
      }
      cout << maxn << endl;
    }
  }
  return 0;
}
