N, M, K = map(int, input().split()) A = list(map(int, input().split())) B = list(map(int, input().split())) Ac, Bc = [0] * N, [0] * M Ac[0], Bc[0] = A[0], B[0] for i in range(1, N): Ac[i] = Ac[i - 1] ^ A[i] for i in range(1, M): Bc[i] = Bc[i - 1] ^ B[i] N2 = 1 << 10 a1, b1 = [0] * N2, [0] * N2 a2, b2 = [0] * N2, [0] * N2 for a in Ac: a1[a] += 1 for b in Bc: b1[b] += 1 mod = 10**9 + 7 ans = 0 for i in range(N2): for j in range(i, N2): if i == j: a2[0] += a1[i] * (a1[i] - 1)//2 b2[0] += b1[i] * (b1[i] - 1)//2 else: a2[i^j] += a1[i] * a1[j] b2[i^j] += b1[i] * b1[j] for i in range(N2): ans += (a1[i] + a2[i]) * (b1[i^K] + b2[i^K]) ans %= mod print(ans)