N2 = 1 << 10 def f(X): ans = [0] * N2 pre = [0] * N2 dp = [0] * N2 for i in range(len(X)): for j in range(N2): v = pre[j ^ X[i]] dp[j] = v ans[j] += v dp[X[i]] += 1 ans[X[i]] += 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)