#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),nbs(1<<15); int main(){ int n, q; cin >> n >> q >> seed; for (int i = 0; i < 10000; i++) next(); vl 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(v[i]+base*q); } rep(bit,1<<16){ for(auto p:bs[bit]){ nbs[(p>>16)&mask].emplace_back(p); } } ll ans=0; ll cnt=0; rep(bit,1<<15){ for(auto p:nbs[bit]){ ll t=p>>35; //cout << ((p.first>>16)&mask) << " " << ((p.first)&mask) << endl; if(t==q)cnt++; else ans^=t*cnt; } } cout << ans << endl; }