#line 1 "a.cpp" #include using namespace std; #line 1 "/home/kotatsugame/library/datastructure/DST.cpp" //Disjoint Sparse Table #include #include template struct DST{ functioncalcfn; int n; vector >dat; DST(const vector&v={}, functioncalcfn_=[](T a,T b){return a(n)); for(int j=i;jn)r=n; r--; if(l==r)return dat[0][l]; int k=31-__builtin_clz(l^r); return calcfn(dat[k][l],dat[k][r]); } }; #line 4 "a.cpp" int N; long a[2<<17]; int pre[2<<17][60]; int Q; main() { cin>>N; for(int i=0;i>a[i]; for(int j=0;j<60;j++)pre[0][j]=-1; for(int i=0;i>j&1)pre[i+1][j]=i; } DSTP(vector(a,a+N),[](long a,long b){return a|b;}); cin>>Q; for(;Q--;) { long b;cin>>b; long A=b,B=~b&(1L<<60)-1; int id=N; int ans=0; while(A&&id>0) { int nid=-1; for(int j=0;j<60;j++)if(B>>j&1&&pre[id][j]>nid)nid=pre[id][j]; if(nid+1=0) { if(A&a[id])break; long tA=B&~a[id],tB=A; A=tA,B=tB; ans++; } } if(A==0)cout<