#include #include #include using namespace std; unsigned long seed; int next(){ seed = seed ^ (seed << 13); seed = seed ^ (seed >> 7); seed = seed ^ (seed << 17); return (seed >> 33); } const long nums_unordered_size = long(1e7); const int module = 220; int main(){ int N, Q; cin >> N >> Q >> seed; for(int i = 0; i < 10000; i++){ next(); } vector nums_unordered[nums_unordered_size]; for(int i = 0; i < N; i++){ long num = next(); nums_unordered[num % module].push_back(num); } long nums_unordered_cumulative_sum[nums_unordered_size]; nums_unordered_cumulative_sum[0] = 0; for(int i = 1; i < nums_unordered_size; i++){ nums_unordered_cumulative_sum[i] = nums_unordered_cumulative_sum[i - 1] + nums_unordered[i - 1].size(); } long ans = 0; for(int i = 0; i < Q; i++){ int query = next(), query_mod = query % module; long this_ans = nums_unordered_cumulative_sum[query_mod]; if(nums_unordered[query_mod].empty()){ ans ^= this_ans * i; }else{ bool if_xored = false; for(int j = 0; j < nums_unordered[query_mod].size(); j++){ if(nums_unordered[query_mod][j] >= query){ ans ^= (this_ans + j) * i; if_xored = true; break; } } if(!if_xored){ ans ^= (this_ans + nums_unordered[query_mod].size()) * i; } } } cout << ans << endl; }