#include using namespace std; #define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i ) #define rep(i,n) REP(i,0,n) using ll = long long; ll res[2][30]; int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); int n,q; cin>>n>>q; vector a(n); rep(i,n)cin>>a[i]; string s;cin>>s; rep(i,2)rep(j,30){ int cur = i; rep(k,n){ int nxt = cur; if(s[k]=='0')nxt &= (a[k]>>j)&1; else nxt |= (a[k]>>j)&1; if(nxt != cur) res[i][j]++; cur = nxt; } } rep(i,q){ int t; cin>>t; ll ans = 0; rep(j,30)ans += (1ll<>j)&1][j]; cout << ans << endl; } return 0; }