n, m, k = map(int, input().split()) A = list(map(int, input().split())) B = list(map(int, input().split())) mod = 10**9+7 def func(A): n = len(A) cnt = [0]*(1<<10) total = 0 cnt[0] = 1 for a in A: total ^= a cnt[total] += 1 res = [0]*(1<<10) for i in range(1<<10): for j in range(i+1, 1<<10): res[i^j] += cnt[i]*cnt[j] for i in range(1<<10): res[i^i] += cnt[i]*(cnt[i]-1)//2 return res CA = func(A) CB = func(B) ans = 0 for a in range(1<<10): for b in range(1<<10): if a^b == k: ans += CA[a]*CB[b] ans %= mod print(ans)