import java.io.BufferedReader; import java.io.InputStreamReader; 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]; long[] now = new long[mx]; for (int i = 0; i < a.length; i++) { long[] next = new long[mx]; for (int j = 0; j < mx; j++) { next[j ^ a[i]] += now[j]; } next[a[i]]++; for (int j = 0; j < mx; j++) { next[j] %= mod; } for (int j = 0; j < mx; j++) { dp[j] += next[j]; dp[j] %= mod; } now = next; } return dp; } }