n, m, k = map(int, input().split()) A = list(map(int, input().split())) B = list(map(int, input().split())) from collections import Counter mod = 10**9+7 CA = [0] for a in A: CA.append(CA[-1]^a) CB = [0] for b in B: CB.append(CB[-1]^b) DA = Counter() SA = Counter() for i, c in enumerate(CA): for j, v in SA.items(): DA[j^c] += v SA[c] += 1 DB = Counter() SB = Counter() for i, c in enumerate(CB): for j, v in SB.items(): DB[j^c] += v SB[c] += 1 ans = 0 for i in range((1<<10)+1): ans += DA[i]*DB[k^i] ans %= mod print(ans)