#include using namespace std; typedef signed long long ll; #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x<(to);x++) #define FORR(x,arr) for(auto& x:arr) #define FORR2(x,y,arr) for(auto& [x,y]:arr) #define ALL(a) (a.begin()),(a.end()) #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,0xff,sizeof(a)) template bool chmax(T &a, const T &b) { if(a bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;} //------------------------------------------------------- int N,Q; string S; struct node { ll v0; //全体が0/1 ll v1; ll v1f; //途中で1で終わる ll o00; //0を受けて0になる ll o01; ll o10; ll o11; ll o01f; //01をうけ途中で1で終わる ll o11f; }; node def={0,0,0,1,0,0,1,0,0}; template class SegTree_ma { public: vector val; V comp(V l,V r){ V m; m.v0=r.v0+l.v0*r.o00+l.v1*r.o10; m.v1=r.v1+l.v0*r.o01+l.v1*r.o11; m.v1f=l.v1f+r.v1f+l.v0*r.o01f+l.v1*r.o11f; m.o00=l.o00*r.o00+l.o01*r.o10; m.o01=l.o00*r.o01+l.o01*r.o11; m.o10=l.o10*r.o00+l.o11*r.o10; m.o11=l.o10*r.o01+l.o11*r.o11; m.o01f=l.o01f+l.o00*r.o01f+l.o01*r.o11f; m.o11f=l.o11f+l.o10*r.o01f+l.o11*r.o11f; return m; }; SegTree_ma(){ val.resize(2*NV,def); }; V getval(int x,int y,int l=0,int r=NV,int k=1) { // x<=i1) entry>>=1, val[entry]=comp(val[entry*2],val[entry*2+1]); } }; SegTree_ma st; node create_node(string v) { if(v=="T") return {0,1,1, 0,0,0,0, 0,0}; if(v=="F") return {1,0,0, 0,0,0,0, 0,0}; if(v=="+T") return {0,1,1, 0,1,0,1, 1,1}; if(v=="*F") return {1,0,0, 1,0,1,0, 0,0}; if(v=="^T") return {0,1,1, 0,1,1,0, 1,0}; if(v=="+F") return {1,0,0, 1,0,0,1, 0,1}; if(v=="*T") return {0,1,1, 1,0,0,1, 0,1}; if(v=="^F") return {1,0,0, 1,0,0,1, 0,1}; return node{}; } void solve() { int i,j,k,l,r,x,y; string s; cin>>N>>Q>>S; N=N/2+1; for(i=1;i>x>>y; x=(x-1)/2; y=(y-1)/2; auto p=create_node(S.substr(x*2,1)); auto q=st.getval(x+1,y+1); auto r=st.comp(p,q); cout<