import java.util.*; public class Main { static long seed; static int next() { seed = seed ^ (seed << 13); seed = seed ^ (seed >>> 7); seed = seed ^ (seed << 17); return (int)(seed >>> 33); } static final long B = 300000; static final long S = (1L<<32) / B + 1; static int n; static int[] a, L, R; public static void first() { L = new int[(int)B]; R = new int[(int)B]; int c = 0; for (int i = 0; i < B; i++) { L[i] = c; while (c < n && (int)(a[c] / S) == i) c++; R[i] = c; } } public static int query(int x) { int i = (int)(x / S); int l = L[i]-1, r = R[i]; while (r-l > 1) { int md = (l+r)/2; if (a[md] < x) { l = md; } else { r = md; } } return r; } public static void main(String[] args) { Scanner sc = new Scanner(System.in); n = sc.nextInt(); int q = sc.nextInt(); seed = sc.nextLong(); for (int i = 0; i < 10000; i++) next(); a = new int[n]; for (int i = 0; i < n; i++) a[i] = next(); Arrays.sort(a); first(); long sm = 0; for (int i = 0; i < q; i++) { int x = next(); sm ^= (long)(query(x)) * i; } System.out.println(sm); } }