#include #include using namespace std; int n, q, b[200009], a[50000009], c[65555], p[50000009], pp[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] & 65535) + 1]++; } for (int i = 0; i < 65536; i++) { c[i + 1] += c[i]; } for (int i = 0; i < q; i++) { pp[c[a[i] & 65535]++] = i; } for (int i = 0; i < 32769; i++) { c[i] = 0; } for (int i = 0; i < q; i++) { c[(a[i] >> 16) + 1]++; } for (int i = 0; i < 32768; i++) { c[i + 1] += c[i]; } for (int i = 0; i < q; i++) { p[c[a[pp[i]] >> 16]++] = pp[i]; } 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; }