import java.util.ArrayList; import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { new Main().run(); } long seed; int next() { seed = seed ^ (seed << 13); seed = seed ^ (seed >>> 7); seed = seed ^ (seed << 17); return (int) (seed >>> 33); } void run() { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int q = sc.nextInt(); seed = sc.nextLong(); for (int i = 0; i < 10000; i++) next(); int[] a = new int[n]; for (int i = 0; i < n; i++) { a[i] = next(); } Arrays.sort(a); int[] cnt = new int[1 + (1 << (32 - 12))]; for (int i = 0; i < n; ++i) { ++cnt[1 + (a[i] >> 12)]; } for (int i = 0; i < cnt.length; ++i) { if (i - 1 > 0) cnt[i] += cnt[i - 1]; } long sm = 0; for (int i = 0; i < q; i++) { int x = next(); int low = cnt[(x >> 12)]; int high = cnt[1 + (x >> 12)]; while (high - low > 1) { int middle = (low + high)>>1; if (a[middle - 1] < x) { low = middle; } else { high = middle; } } if (high != low && a[high - 1] < x) low = high; sm ^= (long) low * i; } System.out.println(sm); } static void tr(Object... objects) { System.out.println(Arrays.deepToString(objects)); } }