#include "bits/stdc++.h" using namespace std; #define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i)) #define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i)) #define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i)) static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL; typedef vector vi; typedef pair pii; typedef vector > vpii; typedef long long ll; template static void amin(T &x, U y) { if (y < x) x = y; } template static void amax(T &x, U y) { if (x < y) x = y; } int main() { int N; int Q; unsigned long long seed; while (~scanf("%d%d%llu", &N, &Q, &seed)) { auto next = [&seed]() { seed = seed ^ (seed << 13); seed = seed ^ (seed >> 7); seed = seed ^ (seed << 17); return (int)(seed >> 33); }; rep(i, 10000) next(); vector A(N); rep(i, N) A[i] = next(); sort(A.begin(), A.end()); vector> buckets(1 << 15); for(int a : A) buckets[a >> 16].push_back(a); vector sumSize(buckets.size() + 1); rep(i, buckets.size()) sumSize[i + 1] = sumSize[i] + (int)buckets[i].size(); ll anssum = 0; rep(qi, Q) { int x = next(); int ans = sumSize[x >> 16]; auto &v = buckets[x >> 16]; ans += (int)(lower_bound(v.begin(), v.end(), x) - v.begin()); anssum ^= (ll)ans * qi; } printf("%lld\n", anssum); } return 0; }