#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ll = long long; using P = pair; constexpr int INF = 1001001001; // constexpr int mod = 1000000007; constexpr int mod = 998244353; template inline bool chmax(T& x, T y){ if(x < y){ x = y; return true; } return false; } template inline bool chmin(T& x, T y){ if(x > y){ x = y; return true; } return false; } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int N, Q, t; vector A(N); string s; cin >> N >> Q; for(int i = 0; i < N; ++i) cin >> A[i]; cin >> s; vector> W(35, vector(5)); for(int k = 0; k < 30; ++k){ for(int j = 0; j < 2; ++j){ int x = j; for(int i = 0; i < N; ++i){ int nx = x; if(s[i] == '0') nx &= (A[i] >> k) & 1; else nx |= (A[i] >> k) & 1; W[k][j] += abs(nx - x); x = nx; } } } for(int i = 0; i < Q; ++i){ cin >> t; ll ans = 0; for(int k = 0; k < 30; ++k){ ans += W[k][t & 1] * (1LL << k); t >>= 1; } cout << ans << '\n'; } return 0; }