#include #define rep(i,n) for(int i = 0; i < (n); ++i) #define srep(i,s,t) for (int i = s; i < t; ++i) #define drep(i,n) for(int i = (n)-1; i >= 0; --i) using namespace std; typedef long long int ll; typedef pair P; #define yn {puts("YES");}else{puts("NO");} #define MAX_N 200005 int main() { int n, q; cin >> n >> q; int a[n] = {}; rep(i,n) cin >> a[i]; string s; cin >> s; ll sum[32][2]; rep(i,32)rep(j,2) sum[i][j] = 0; int now[32][2]; rep(i,32)rep(j,2) now[i][j] = j; rep(i,n){ bitset<32> bi(a[i]); rep(j,32){ rep(k,2){ if(s[i] == 0){ if(now[j][k] == 1 && bi[j] == 0){ sum[j][k] += 1 << j; now[j][k] = 0; } }else{ if(now[j][k] == 0 && bi[j] == 1){ sum[j][k] += 1 << j; now[j][k] = 1; } } } } } rep(_,q){ int t; cin >> t; bitset<32> bi(t); ll ans = 0; rep(j,32){ ans += sum[j][bi[j]]; } cout << ans << endl; } return 0; }