#include #include #include using namespace std; using uint = unsigned int; using ll = long long; using ull = unsigned long long; ull seed; uint next() { seed = seed ^ (seed << 13); seed = seed ^ (seed >> 7); seed = seed ^ (seed << 17); return (seed >> 33); } int main() { int n, q; cin >> n >> q >> seed; for (int i = 0; i < 10000; ++i) { next(); } vector a(n); for (int i = 0; i < n; i++) { a[i] = next(); } sort(a.begin(), a.end()); a.push_back(0xffffffff); const uint shift = 11; const uint types = 1 << (31 - shift); vector b(types + 1); uint curr = 0; for (int i = 0; i < n; ++i) { if (a[i] >= (curr << shift)) { b[curr] = i; ++curr; --i; } } b[types] = n; ll ans = 0; for (int i = 0; i < q; ++i) { uint x = next(); uint s = x >> shift; uint cnt = b[s]; while (a[cnt] < x) { ++cnt; } ans ^= ll(cnt) * i; } cout << ans << endl; return 0; }