import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string; auto rdsp(){return readln.splitter;} void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;} void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);} ulong seed; int next() { seed = seed ^ (seed << 13); seed = seed ^ (seed >> 7); seed = seed ^ (seed << 17); return cast(int)(seed >> 33); } void main() { int n, q; readV(n, q, seed); foreach (i; 0..10000) next(); auto a = new int[](n); foreach (i; 0..n) a[i] = next(); auto b = new int[][](1<<20); foreach (ai; a) b[ai>>11] ~= ai; auto c = b.map!(bi => bi.length.to!int).array; auto cc = cumulativeSum(c); auto ans = 0uL; foreach (i; 0..q) { auto x = next(); ans ^= (cc[0..x>>11] + b[x>>11].count!(bi => bi < x)) * i; } writeln(ans); } class CumulativeSum(T) { size_t n; T[] s; this(T[] a) { n = a.length; s = new T[](n+1); s[0] = T(0); foreach (i; 0..n) s[i+1] = s[i] + a[i]; } T opSlice(size_t l, size_t r) { return s[r]-s[l]; } size_t opDollar() { return n; } } auto cumulativeSum(T)(T[] a) { return new CumulativeSum!T(a); }