#include using namespace std; #define rep(i,n) for(ll i=0;i=0;i--) #define perl(i,r,l) for(ll i=r-1;i>=l;i--) #define fi first #define se second #define pb push_back #define ins insert #define pqueue(x) priority_queue,greater> #define all(x) (x).begin(),(x).end() #define CST(x) cout<> #define rev(x) reverse(x); using ll=long long; using vl=vector; using vvl=vector>; using pl=pair; using vpl=vector; using vvpl=vector; const ll MOD=1000000007; const ll MOD9=998244353; const int inf=1e9+10; const ll INF=4e17; const ll dy[9]={0,1,-1,0,1,1,-1,-1,0}; const ll dx[9]={1,0,0,-1,1,-1,1,-1,0}; template inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } template inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } using ull = unsigned long long; ull seed; int next() { seed = seed ^ (seed << 13); seed = seed ^ (seed >> 7); seed = seed ^ (seed << 17); return (seed >> 33); } vvl bs(1<<16); vector> nbs(1<<15); int main(){ //頑張ったけどメモリが足りず涙 サンプル3で3300ms、853MB int n, q; cin >> n >> q >> seed; for (int i = 0; i < 10000; i++) next(); vector v(n);rep(i,n)v[i]=next(); ll mask=(1<<16)-1; ll base=1LL<<35; rep(i,q){ ll a=next(); bs[a&mask].emplace_back(a+base*i); } rep(i,n){ bs[v[i]&mask].emplace_back(base*q+v[i]); } rep(bit,1<<16){ for(auto p:bs[bit]){ nbs[(p>>16)&mask].emplace_back(p>>35); } } ll ans=0; ll cnt=0; rep(bit,1<<15){ for(auto p:nbs[bit]){ if(p==q)cnt++; else ans^=p*cnt; } } cout << ans << endl; }