def f(A): a0=0 P=defaultdict(int) AA=defaultdict(int) for a in A: a0^=a for p,val in P.items(): AA[a0^p]+=val AA[a0^p]%=MOD P[a0]+=1 AA[a0]+=1 return AA from collections import defaultdict MOD=10**9+7 N,M,K=map(int, input().split()) A=list(map(int, input().split())) B=list(map(int, input().split())) A=f(A) B=f(B) cnt=0 for a,val_a in A.items(): for b,val_b in B.items(): if a^b==K: cnt+=val_a*val_b cnt%=MOD print(cnt)