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 Pair implements Comparable { int q; long value; public Pair(int q, long value){ this.q = q; this.value = value; } @Override public int compareTo(Pair o) { return Long.compare(this.value, o.value); } } 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(); } Arrays.sort(array); Pair[] query = new Pair[Q]; for(int q = 0; q < Q; q++){ query[q] = new Pair(q, next()); } Arrays.sort(query); long answer = 0; int count = 0; for(final Pair q : query){ while(count < N && array[count] < q.value){ count++; } final long q_answer = count; answer ^= q_answer * q.q; } System.out.println(answer); } }