n,m,k = map(int,input().split()) a = list(map(int,input().split())) b = list(map(int,input().split())) mod = 10**9+7 ax = [0]*1024 bx = [0]*1024 for xx,x in zip([ax,bx],[a,b]): tmp = 0 # xx[0] += 1 for xi in x: tmp = tmp^xi xx[tmp] += 1 ax2 = ax[::] bx2 = bx[::] for xx,xx2 in zip([ax,bx],[ax2,bx2]): for i in range(1024-1): for j in range(i,1024): if(i==j): xx2[0] += (xx[i]*(xx[i]-1))//2 xx2[0] %= mod else: xx2[i ^ j] += xx[i]*xx[j] xx2[i ^ j] %= mod ans = 0 for i in range(1024): ans += ax2[i] * bx2[k^i] ans %= mod print(ans)