#include #include #include #include #include #include #include #include #include #include using namespace std; using ll = long long; using ull = unsigned long long; ull seed; int 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()); ll sm = 0; int w; int c; double b1 = 1.0 / ((long long)1 << 31); double it = n*b1; for (int i = 0; i < q; i++) { int x = next(); c = (double)x * n * b1; //cerr << c << endl; /*if (c < 0 || c >= n) { cerr << x << " " << n << " " << b1 << endl; cerr << c << endl; }*/ w = n; while (true) { if (a[c] < x) { if (c == n - 1 || a[c + 1] >= x) { c++; break; } w = max(2.0, min(w - 2.0,(x - a[c]) * it)); c += w; if (c >= n)c = n - 1; } else { if (c == 0 || a[c - 1] < x)break; w = max(2.0, min(w - 2.0, (a[c] - x) * it)); c -= w; if (c < 0)c = 0; } } sm ^= ll(c) * i; } cout << sm << endl; return 0; }