n, q = map(int, input().split()) A = list(map(int, input().split())) S = input() U = 31 dp = [[0]*U for _ in range(2)] for i in range(2): for j in range(U): now, temp = i, 0 for k, a in enumerate(A): if S[k] == "0": nxt = now & (a>>j & 1) temp += now - nxt now = nxt else: nxt = now | (a>>j & 1) temp += nxt - now now = nxt dp[i][j] = temp T = list(map(int, input().split())) for t in T: ans = 0 for j in range(U): ans += dp[t>>j & 1][j] << j print(ans)