#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 SegmentTree{ using F=function; int sz; vector seg; const F f; const Monoid e; SegmentTree(int n, const F f, const Monoid &e): f(f), e(e){ sz=1; while(sz v): f(f), e(e){ sz=1; while(sz=1; i--){ seg[i]=f(seg[2*i], seg[2*i+1]); } } void update(int k, const Monoid &x){ k+=sz; seg[k]=x; while(k>1){ k>>=1; seg[k]=f(seg[2*k], seg[2*k+1]); } } Monoid query(int a, int b){ a+=sz, b+=sz; Monoid ret=e; for(;a>=1, b>>=1){ if(b&1) ret=f(ret, seg[--b]); if(a&1) ret=f(ret, seg[a++]); } return ret; } /*Monoid query(int a, int b){ //演算が非可換のとき a+=sz, b+=sz; Monoid retl=e, retr=e; for(;a>=1, b>>=1){ if(b&1) retr=f(seg[--b], retr); if(a&1) retl=f(retl, seg[a++]); } return f(retl, retr); }*/ Monoid operator[](const int &k) const{ return seg[k+sz]; } }; const ll MOD=1e9+7; ll powmod(ll a, ll k){ ll ap=a, ans=1; while(k){ if(k&1){ ans*=ap; ans%=MOD; } ap=ap*ap; ap%=MOD; k>>=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; SegmentTree> seg(n, 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<