def xoracc(X): r = 0 table = [0] * (1 << 10) table[0] = 1 for x in X: r ^= x table[r] += 1 table2 = [0] * (1 << 10) for i, ci in enumerate(table): for j, cj in enumerate(table): table2[i ^ j] += ci * cj table2[0] -= len(X) + 1 for i in range(1 << 10): table2[i] //= 2 return table2 N, M, K = map(int, input().split()) A = tuple(map(int, input().split())) B = tuple(map(int, input().split())) MOD = 10 ** 9 + 7 ans = 0 AT = xoracc(A) BT = xoracc(B) for i in range(1 << 10): j = K ^ i ans += AT[i] * BT[j] ans %= MOD print(ans)