from itertools import accumulate from collections import Counter from operator import xor n, m, k = map(int, input().split()) A = list(map(int, input().split())) B = list(map(int, input().split())) mod = 10 ** 9 + 7 def make_cnt(A): Axor = list(accumulate(A, func=xor, initial=0)) C = Counter(Axor) cnt = [0] * 1024 for i in range(1024): cnt[0] += C[i] * (C[i] - 1) // 2 for j in range(i + 1, 1024): cnt[i ^ j] += C[i] * C[j] cnt[i ^ j] %= mod return cnt Acnt = make_cnt(A) Bcnt = make_cnt(B) ans = 0 for i in range(1024): ans += Acnt[i] * Bcnt[k ^ i] ans %= mod print(ans)