mod=10**9+7 inv=pow(2,mod-2,mod) def xorconv(n,X,Y): if n==0: res=[(X[0]*Y[0])%mod] return res x=[X[i]+X[i+2**(n-1)] for i in range(2**(n-1))] y=[Y[i]+Y[i+2**(n-1)] for i in range(2**(n-1))] z=[X[i]-X[i+2**(n-1)] for i in range(2**(n-1))] w=[Y[i]-Y[i+2**(n-1)] for i in range(2**(n-1))] res1=xorconv(n-1,x,y) res2=xorconv(n-1,z,w) former=[(res1[i]+res2[i])*inv for i in range(2**(n-1))] latter=[(res1[i]-res2[i])*inv for i in range(2**(n-1))] former=list(map(lambda x:x%mod,former)) latter=list(map(lambda x:x%mod,latter)) return former+latter N,M,K=map(int,input().split()) 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] dataA=[0]*1024 for i in range(N+1): dataA[a[i]]+=1 dataB=[0]*1024 for i in range(M+1): dataB[b[i]]+=1 #print(dataA[:9]) #print(dataB[:9]) A=xorconv(10,dataA,dataA) B=xorconv(10,dataB,dataB) #print(A[:9]) #print(B[:9]) temp=0 for i in range(N+1): temp=(temp+dataA[i]*(dataA[i]-1)//2) temp%=mod A[0]=temp for i in range(1,1024): A[i]=(A[i]*inv)%mod temp=0 for i in range(M+1): temp=(temp+dataB[i]*(dataB[i]-1)//2) temp%=mod B[0]=temp for i in range(1,1024): B[i]=(B[i]*inv)%mod ans=0 for i in range(1024): ans=(ans+A[i]*B[i^K])%mod print(ans)