import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.LinkedList; import java.util.Scanner; import java.util.TreeSet; public class Main { public static final long MOD = 1000000007; static long seed; static int next() { seed = seed ^ (seed << 13); seed = seed ^ (seed >>> 7); seed = seed ^ (seed << 17); return (int)(seed >>> 33); } public static class BIT { long[] dat; public BIT(int n){ dat = new long[n + 1]; } public void add(int k, int a){ // k : 0-indexed for(int i = k + 1; i < dat.length; i += i & -i){ dat[i] += a; } } public long sum(int s, int t){ // [s, t) if(s > 0) return sum(0, t) - sum(0, s); long ret = 0; for(int i = t; i > 0; i -= i & -i) { ret += dat[i]; } return ret; } } public static void main(String[] args) { Scanner sc = new Scanner(System.in); final int N = sc.nextInt(); final int Q = sc.nextInt(); seed = sc.nextLong(); for (int i = 0; i < 10000; i++){ next();} int[] array = new int[N]; for(int i = 0; i < N; i++){ array[i] = next(); } TreeSet values = new TreeSet(); for(int i = 0; i < N; i++){ values.add(array[i]); } ArrayList sorted = new ArrayList(values); BIT bit = new BIT(N); for(int i = 0; i < N; i++){ final int index = Collections.binarySearch(sorted, array[i]); //System.out.println(i + " " + array[i] + " " + index); bit.add(index, 1); } long answer = 0; for(int q = 0; q < Q; q++){ final int x = next(); final int x_index = Collections.binarySearch(sorted, x); //System.out.println(x); //System.out.println(values.subSet(0, x)); if(x_index >= 0){ //System.out.println(bit.sum(0, x_index) * q); answer ^= bit.sum(0, x_index) * q; }else{ final int x_index2 = -(x_index + 1); //System.out.println(q + " " + x_index2 + " " + bit.sum(0, x_index2) + " " + bit.sum(0, x_index2) * q); answer ^= bit.sum(0, x_index2) * q; } } System.out.println(answer); } }