#include #include #define MAXN 200010 int compareInt(const void* a, const void* b); int next(); unsigned long long seed; int a[MAXN]; int main() { int n, q; scanf("%d%d%llu", &n, &q, &seed); for(int i = 0; i < 10000; i++) next(); for(int i = 0; i < n; i++) a[i] = next(); qsort(a, n, sizeof(int), compareInt); long long ans = 0; for(int i = 0; i < q; i++) { int x = next(); int ub = n, mid, lb = -1; while(ub-lb != 1) { mid = (ub+lb)>>1; if(a[mid] >= x) ub = mid; else lb = mid; } ans ^= (long long)ub*i; } printf("%lld\n", ans); return 0; } int compareInt(const void* a, const void* b) { int aNum = *(int*)a; int bNum = *(int*)b; if( aNum < bNum ){ return -1; } else if( aNum > bNum ){ return 1; } return 0; } int next() { seed = seed ^ (seed << 13); seed = seed ^ (seed >> 7); seed = seed ^ (seed << 17); return (seed >> 33); }