import sys input = sys.stdin.readline N, M, K = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) now = 0 cnt = [0]*1024 cnt[0] = 1 for ai in a: now ^= ai cnt[now] += 1 cnt2 = [0]*1024 for i in range(1024): for j in range(i): cnt2[i^j] += cnt[i]*cnt[j] cnt2[0] += cnt[i]*(cnt[i]-1)//2 now = 0 cnt3 = [0]*1024 cnt3[0] = 1 for bi in b: now ^= bi cnt3[now] += 1 cnt4 = [0]*1024 for i in range(1024): for j in range(i): cnt4[i^j] += cnt3[i]*cnt3[j] cnt4[0] += cnt3[i]*(cnt3[i]-1)//2 ans = 0 MOD = 10**9+7 for i in range(1024): ans = (ans+cnt2[i]*cnt4[i^K])%MOD print(ans)