#include using namespace std; typedef long long int ll; constexpr int kN = int(1E5 + 10); int a[kN], t[kN]; int main() { int n, q, x = 0, y = 0; ll tot = 0; string s; cin >> n >> q; for (int i = 1; i <= n; i++) cin >> a[i]; cin >> s; for (int i = 1; i <= q; i++) cin >> t[i]; reverse(s.begin(), s.end()); reverse(a + 1, a + n + 1); for (int i = 1; i <= n; i++) if (s[i - 1] == '0') { x |= ~a[i]; tot += y ^ (y & ~x); y &= ~x; } else { y |= a[i]; tot += x ^ (x & ~y); x &= ~y; } //cout << x << ' ' << y << ' ' << tot << '\n'; //for (int i = 1; i <= q; i++) cout << t[i] << '\n'; for (int i = 1; i <= q; i++) cout << tot + (t[i] & x) + (~t[i] & y) << '\n'; }