n,m,k = map(int,input().split()) A = list(map(int,input().split())) B = list(map(int,input().split())) M = 1<<10 mod = 10**9+7 ca = [0]*M cb = [0]*M ca[0] += 1 cb[0] += 1 num = 0 for a in A: num ^= a ca[num] += 1 num = 0 for b in B: num ^= b cb[num] += 1 sA,sB = [0]*M,[0]*M for i in range(M): for j in range(i+1): if i == j: sA[0] += ca[i]*(ca[i]-1)//2 sA[0] %= mod sB[0] += cb[i]*(cb[i]-1)//2 sB[0] %= mod else: sA[i^j] += ca[i]*ca[j] sA[i^j] %= mod sB[i^j] += cb[i]*cb[j] sB[i^j] %= mod ans = 0 for i in range(M): ans += sA[i]*sB[k^i]%mod ans %= mod print(ans)