import java.io.*; import java.util.*; 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[] current = new long[1024]; long[] next = new long[1024]; long[] sumA = new long[1024]; for (int i = 0; i < n; i++) { int x = sc.nextInt(); next[x]++; sumA[x]++; for (int j = 0; j < 1024; j++) { next[x ^ j] += current[j]; next[x ^ j] %= MOD; sumA[x ^ j] += current[j]; sumA[x ^ j] %= MOD; } long[] tmp = current; current = next; next = tmp; Arrays.fill(next, 0); } long[] sumB = new long[1024]; Arrays.fill(current, 0); for (int i = 0; i < m; i++) { int x = sc.nextInt(); next[x]++; sumB[x]++; for (int j = 0; j < 1024; j++) { next[x ^ j] += current[j]; next[x ^ j] %= MOD; sumB[x ^ j] += current[j]; sumB[x ^ j] %= MOD; } long[] tmp = current; current = next; next = tmp; Arrays.fill(next, 0); } long ans = 0; for (int i = 0; i < 1024; i++) { ans += sumA[i] * sumB[i ^ k] % MOD; ans %= MOD; } System.out.println(ans); } } 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 String next() throws Exception { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }