#include using namespace std; using ll = long long; using ul = unsigned long; using ull = unsigned long long; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n, q; cin >> n >> q; vector a(n); for (auto&& it : a) cin >> it; string s; cin >> s; stringstream ss; for (int i = 0; i < q; ++i) { ll t, t0, score{ 0 }; cin >> t; t0 = t; for (size_t j = 0; j < s.size(); ++j) { if (s[j] == '0') t &= a[j]; else t |= a[j]; score += abs(t - t0); t0 = t; } ss << score << "\n"; } cout << ss.str(); return 0; }