import java.io.*; public class Main { static int mod = 1000000007; public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] line = br.readLine().split(" "); int n = Integer.parseInt(line[0]); int m = Integer.parseInt(line[1]); int k = Integer.parseInt(line[2]); int a[] = new int[n], b[] = new int[m]; line = br.readLine().split(" "); for(int i = 0; i < n; i++) a[i] = Integer.parseInt(line[i]); line = br.readLine().split(" "); for(int i = 0; i < m; i++) b[i] = Integer.parseInt(line[i]); int acca[] = new int[1<<10], ax[] = new int[1<<10], accb[] = new int[1<<10], bx[] = new int[1<<10]; acca[0] = accb[0] = 1; int tmp = 0; for(int i = 0; i < n; i++){ tmp ^= a[i]; for(int j = 0; j < 1<<10; j++){ ax[j^tmp] += acca[j]; ax[j^tmp] %= mod; } acca[tmp]++; } tmp = 0; for(int i = 0; i < m; i++){ tmp ^= b[i]; for(int j = 0; j < 1<<10; j++){ bx[j^tmp] += accb[j]; bx[j^tmp] %= mod; } accb[tmp]++; } long ans = 0; for(int i = 0; i < 1<<10; i++){ ans += (long)(ax[i]) * bx[k^i] % mod; ans %= mod; } System.out.println(ans); } }