#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define popcount __builtin_popcount using namespace std; typedef long long int ll; typedef pair P; using uint=unsigned int; uint a[10010]; vector Gauss_Jordan(vector &v){ //v[i]<2^MAX int n=v.size(); vector w(n); for(int i=0; i b(n); for(int i=0; i<32; i++){ int p=-1; for(int j=0; j>i)&1){ b[j]=1; p=j; break; } } if(p==-1) continue; for(int j=p+1; j>i)&1){ w[j]^=w[p]; } } } vector ret; for(int j=0; j struct SparseTable{ using F=function; const F f; const T e; vector> spt; vector vlog; SparseTable(const F f, const T &e, const vector &v):f(f), e(e){ int b=0, n=v.size(); while((1<(n)); for(int i=0; i>1]+1; } T query(int l, int r){ int b=vlog[r-l]; return f(spt[b][l], spt[b][r-(1<>=1; } return ans; } ll inv(ll a){ return powmod(a, MOD-2); } int main() { int n, q; cin>>n>>q; for(int i=0; i>a[i]; auto f=[&](vector v, vector w){ v.insert(v.end(), w.begin(), w.end()); return Gauss_Jordan(v); }; vector> va(n); for(int i=0; i0) va[i].push_back(i); vector e; SparseTable> seg(f, e, va); while(q--){ int m; cin>>m; int pr=0; int sum=0; for(int i=0; i>b; int r=seg.query(pr, b).size(); sum+=b-pr-r; pr=b; } sum+=n-pr-(int)seg.query(pr, n).size(); cout<