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(); int[] countsA = new int[1024]; int[] ansA = new int[1024]; for (int i = 0; i < n; i++) { int[] next = new int[1024]; int x = sc.nextInt(); for (int j = 0; j < 1024; j++) { next[j ^ x] += countsA[j]; next[j ^ x] %= MOD; } next[x]++; next[x] %= MOD; countsA = next; for (int j = 0; j < 1024; j++) { ansA[j] += countsA[j]; ansA[j] %= MOD; } } int[] countsB = new int[1024]; int[] ansB = new int[1024]; for (int i = 0; i < m; i++) { int[] next = new int[1024]; int x = sc.nextInt(); for (int j = 0; j < 1024; j++) { next[j ^ x] += countsB[j]; next[j ^ x] %= MOD; } next[x]++; next[x] %= MOD; countsB = next; for (int j = 0; j < 1024; j++) { ansB[j] += countsB[j]; ansB[j] %= MOD; } } long ans = 0; for (int i = 0; i < 1024; i++) { ans += (long)ansA[i] * ansB[i ^ k]; ans %= MOD; } System.out.println(ans); } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); 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 { if (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }