#include using namespace std; using ll = long long; const int mx = 2e5+10; int nnn[mx],now[mx],l[mx],r[mx],ccc[mx],cnc[mx],nxt[mx]; int p[mx]; int n,m,q; const int B = 600; char s[mx]; int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); cin>>n>>m>>q; for(int i = 0;i>p[i]; string a; cin>>a; if(a=="AC") s[i] = 1; } int mx = 2e5; vector> is(mx+1); for(int i = 0;i=0;j--){ if(s[is[i][j]]){ cnc[is[i][j]] = now; nxt[is[i][j]] = ni; now= 0; ni = is[i][j]; }else{ now++; } } } for(int i = 0;i>l[i]>>r[i]; l[i]--; } vector idx(q); for(int i = 0;i r[j]; return r[i] < r[j]; }); int ans = 0; int cnt = 0; int nl = 0; int nr = 1; vector> aa(q); if(s[0]){ ans++; nnn[p[0]]++; now[p[0]]++; }else{ now[p[0]]++; } for(int i = 0;ir[ni]){ nr--; if(s[nr]){ now[p[nr]]--; nnn[p[nr]]--; if(nnn[p[nr]]==0){ cnt -= ccc[p[nr]]; ccc[p[nr]] = 0; ans--; } }else{ now[p[nr]]--; } } aa[ni] = make_pair(ans,cnt); } for(int i = 0;i