n, Q = map(int, input().split()) A = list(map(int, input().split())) S = input() cnt = [[0] * 2 for _ in range(30)] for i in range(30): for j in range(2): if j == 0: x = 0 else: x = 1 << i for a, s in zip(A, S): b = (a >> i & 1) << i if s == "0": nx = x & b else: nx = x | b cnt[i][j] += abs(x - nx) x = nx T = list(map(int, input().split())) for t in T: ans = 0 for i in range(30): ans += cnt[i][t >> i & 1] print(ans)