MOD = 10 ** 9 + 7 n, m, k = map(int, input().split()) A = list(map(int, input().split())) B = list(map(int, input().split())) def f(A): cnt = [0] * 1024 cnt2 = [0] * 1024 cnt2[0] = 1 xor = 0 for a in A: xor ^= a for k in range(1024): cnt[xor ^ k] += cnt2[k] cnt[xor ^ k] %= MOD cnt2[xor] += 1 return cnt A = f(A) B = f(B) ans = 0 for i in range(1024): ans += A[i] * B[i ^ k] ans %= MOD print(ans)