import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.HashMap; import java.util.Map; public class Main { static int mod = 1000000007; static int mx = 1024; public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] sa = br.readLine().split(" "); int n = Integer.parseInt(sa[0]); int m = Integer.parseInt(sa[1]); int k = Integer.parseInt(sa[2]); sa = br.readLine().split(" "); int[] a = new int[n]; for (int i = 0; i < n; i++) { a[i] = Integer.parseInt(sa[i]); } sa = br.readLine().split(" "); int[] b = new int[m]; for (int i = 0; i < m; i++) { b[i] = Integer.parseInt(sa[i]); } br.close(); long[] dpa = dp(a); long[] dpb = dp(b); long ans = 0; for (int i = 0; i < mx; i++) { int j = k ^ i; ans += dpa[i] * dpb[j]; ans %= mod; } System.out.println(ans); } static long[] dp(int[] a) { long[] dp = new long[mx]; Map now = new HashMap<>(); for (int i = 0; i < a.length; i++) { Map next = new HashMap<>(); for (int j : now.keySet()) { int key = j ^ a[i]; next.put(key, next.getOrDefault(key, 0L) + now.get(j)); } next.put(a[i], next.getOrDefault(a[i], 0L) + 1); for (Integer j : next.keySet()) { next.put(j, next.get(j) % mod); dp[j] += next.get(j); dp[j] %= mod; } now = next; } return dp; } }