import java.io.*; import java.util.*; import java.util.stream.*; public class Main { static final int MOD = 1000000007; public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); int m = sc.nextInt(); int k = sc.nextInt(); long[] countsA = new long[1024]; int current = 0; countsA[0]++; for (int i = 0; i < n; i++) { current ^= sc.nextInt(); countsA[current]++; } long[] ansA = new long[1024]; for (int i = 0; i < 1024; i++) { for (int j = i; j < 1024; j++) { if (i == j) { if (countsA[i] % 2 == 0) { ansA[0] += countsA[i] / 2 * (countsA[i] - 1) % MOD; } else { ansA[0] += (countsA[i] - 1) / 2 * countsA[i] % MOD; } ansA[0] %= MOD; } else { ansA[i ^ j] += countsA[i] * countsA[j] % MOD; ansA[i ^ j] %= MOD; } } } long[] countsB = new long[1024]; current = 0; countsB[0]++; for (int i = 0; i < m; i++) { current ^= sc.nextInt(); countsB[current]++; } long[] ansB = new long[1024]; for (int i = 0; i < 1024; i++) { for (int j = i; j < 1024; j++) { if (i == j) { if (countsB[i] % 2 == 0) { ansB[0] += countsB[i] / 2 * (countsB[i] - 1) % MOD; } else { ansB[0] += (countsB[i] - 1) / 2 * countsB[i] % MOD; } ansB[0] %= MOD; } else { ansB[i ^ j] += countsB[i] * countsB[j] % MOD; ansB[i ^ j] %= MOD; } } } long ans = 0; for (int i = 0; i < 1024; i++) { ans += ansA[i] * ansB[i ^ k] % MOD; ans %= MOD; } System.out.println(ans); } } class Utilities { static String arrayToLineString(Object[] arr) { return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n")); } static String arrayToLineString(int[] arr) { return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new)); } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public int[] nextIntArray() throws Exception { return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray(); } public String next() throws Exception { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }