N,M,K=map(int,input().split()) X=1<<10 mod=10**9+7 A=[0]+list(map(int,input().split())) B=[0]+list(map(int,input().split())) for i in range(1,N+1): A[i]^=A[i-1] for i in range(1,M+1): B[i]^=B[i-1] cntA=[0]*X cntB=[0]*X for a in A: cntA[a]+=1 for b in B: cntB[b]+=1 A=[0]*X B=[0]*X for a0 in range(X): for a1 in range(X): A[a0^a1]+=cntA[a0]*cntA[a1] for b0 in range(X): for b1 in range(X): B[b0^b1]+=cntB[b0]*cntB[b1] A[0]-=N+1 B[0]-=M+1 for x in range(X): A[x]//=2 B[x]//=2 ans=0 for x in range(X): ans+=A[x]*B[x^K]%mod ans%=mod print(ans)