N2 = 1 << 10 def f(X): ans = [0] * N2 pre = [0] * N2 dp = [0] * N2 for i in range(len(X)): x = X[i] for j in range(N2): v = pre[j ^ x] dp[j] = v ans[j] += v dp[x] += 1 ans[x] += 1 pre, dp = dp, pre return ans N, M, K = map(int, input().split()) mod = 10 ** 9 + 7 A = list(map(int, input().split())) B = list(map(int, input().split())) DA, DB = f(A), f(B) ans = 0 for i in range(N2): ans += DA[i] * DB[i^K] ans %= mod print(ans)