def solve(): mod = 10**9+7 N, M, K = map(int, input().split()) A = list(map(int, input().split())) B = list(map(int, input().split())) cum_a,cum_b = [0]*(1<<10),[0]*(1<<10) cum_a[0],cum_b[0] = 1,1 now_a,now_b = 0,0 for i in range(N): now_a ^= A[i] cum_a[now_a] += 1 for j in range(M): now_b ^= B[j] cum_b[now_b] += 1 a2,b2 = [0]*(1<<10),[0]*(1<<10) for i in range(1<<10): for j in range(i,1<<10): if i==j: a2[i^j] += cum_a[i]*(cum_a[i]-1)//2 b2[i^j] += cum_b[i]*(cum_b[i]-1)//2 else: a2[i^j] += cum_a[i]*cum_a[j] b2[i^j] += cum_b[i]*cum_b[j] a2[i^j] %= mod b2[i^j] %= mod ans = 0 for i in range(1<<10): j = K^i ans += a2[i]*b2[j] ans %= mod return ans print(solve())