#include using namespace std; #define ALL(a) (a).begin(),(a).end() #define ALLR(a) (a).rbegin(),(a).rend() #define rep(i,n,m) for(int i = (n); i < (int)(m); i++) #define rrep(i,n,m) for(int i = (m) - 1; i >= (int)(n); i--) using ll = long long; using ld = long double; const ll MOD1 = 1e9+7; const ll MOD9 = 998244353; const int INF = (int)1e9+1; template bool chmin(T &a,T b){if(a>b){a=b;return true;}else return false;} template bool chmax(T &a,T b){if(a vectordx={1,0,-1,0,1,1,-1,-1}; vectordy={0,1,0,-1,1,-1,1,-1}; int main(){ int n,q;cin>>n>>q; vectora(n); rep(i,0,n)cin>>a[i]; string s;cin>>s; ll sz=30; vector>score(sz,vector(2,0)); rep(i,0,sz){ rep(j,0,2){ ll now=(1<>t; ll ret=0; rep(i,0,sz){ ret+=score[i][bool(t&1<