#include using namespace std; #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) #define ALL(v) begin(v),end(v) template inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; } template inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; } using ll = long long; using pii = pair; constexpr ll INF = 1ll<<30; constexpr ll longINF = 1ll<<60; constexpr ll MOD = 1000000007; constexpr bool debug = false; //---------------------------------// int main() { int N, Q; cin >> N >> Q; vector A(N); REP(i, N) scanf("%d", &A[i]); string S; cin >> S; vector score(30, vector(2)); REP(i, 30) { REP(j, 2) { int cur = j, s = 0; REP(k, N) { if (S[k] == '0' && cur && ~A[k] >> i & 1) cur = 0, ++s; if (S[k] == '1' && !cur && A[k] >> i & 1) cur = 1, ++s; } score[i][j] = s; } } while (Q--) { int t; scanf("%d", &t); ll ans = 0; REP(i, 30) ans += (1ll << i) * score[i][t >> i & 1]; printf("%lld\n", ans); } }