#include #include #include #include #include #include using namespace std; int ALL,CNT; struct deq{ dequeWA; deq() { WA.push_back(0); } void push_front(bool s) { answer_dec(); if(s)WA.push_front(0); else WA.front()++; answer_inc(); } void push_back(bool s) { answer_dec(); if(s)WA.push_back(0); else WA.back()++; answer_inc(); } void pop_front() { answer_dec(); if(WA.front()>0)WA.front()--; else WA.pop_front(); answer_inc(); } void pop_back() { answer_dec(); if(WA.back()>0)WA.back()--; else WA.pop_back(); answer_inc(); } void answer_dec() { if(WA.size()>=2) { ALL-=WA.front(); CNT--; } } void answer_inc() { if(WA.size()>=2) { ALL+=WA.front(); CNT++; } } }; int N,M,Q; int P[2<<17]; bool S[2<<17]; deq A[200000]; const int B=400; const int MN=200000; vector > >qR[(MN+B-1)/B]; int cnt[2<<17],ans[2<<17]; int main() { cin>>N>>M>>Q; for(int i=0;i>P[i]>>s; P[i]--; S[i]=s=="AC"; } for(int i=0;i>l>>r; l--; qR[l/B].push_back(make_pair(r,make_pair(l,i))); } int nL=0,nR=0; for(int li=0;li*B >&l,const pair >&r) { if(li&1)return l.first>r.first; else return l.first >p:qR[li]) { int l=p.second.first; int r=p.first; while(nL>l) { nL--; A[P[nL]].push_front(S[nL]); } while(nRr) { nR--; A[P[nR]].pop_back(); } cnt[p.second.second]=CNT; ans[p.second.second]=ALL; } } for(int i=0;i