#include #include using namespace std; int n, q, b[200009], a[50000009], c[65555], p[50000009]; unsigned long long seed; int main() { cin >> n >> q >> seed; for (int i = 0; i < 10000; i++) { seed = seed ^ (seed << 13); seed = seed ^ (seed >> 7); seed = seed ^ (seed << 17); } for (int i = 0; i < n; i++) { seed = seed ^ (seed << 13); seed = seed ^ (seed >> 7); seed = seed ^ (seed << 17); b[i] = (seed >> 33); } sort(b, b + n); for (int i = 0; i < q; i++) { seed = seed ^ (seed << 13); seed = seed ^ (seed >> 7); seed = seed ^ (seed << 17); a[i] = (seed >> 33); c[(a[i] >> 16) + 1]++; } for (int i = 0; i < 1 << 16; i++) { c[i + 1] += c[i]; } for (int i = 0; i < q; i++) { p[c[a[i] >> 16]++] = i; } for (int i = 0; i < 1 << 16; i++) { sort(p + c[i], p + c[i + 1], [&](int j, int k) { return a[j] < a[k]; }); } int ptr = 0; long long ret = 0; for (int i = 0; i < q; i++) { while (ptr != n && a[p[i]] > b[ptr]) ptr++; ret ^= 1LL * ptr * p[i]; } cout << ret << endl; return 0; }