#include using namespace std; typedef long long ll; struct t3{int left, right, index;}; bool sec_sort(t3 a, t3 b){return a.right < b.right;} int main(){ int n, m, q; cin >> n >> m >> q; vector prob(n); vector dat(n); vector lftwa(m); vector nowcnt(m); for (int i=0; i> p >> s; p--; prob[i] = p; if (s == "AC"){ dat[i] = 1; lftwa[i] = nowcnt[p]; }else{ dat[i] = 0; nowcnt[p]++; } } int sep = ceil(sqrt(n)); vector> mo(sep+1, vector(0)); t3 f; for(int i=0; i> l >> r; l--; f.left = l; f.right = r; f.index = i; mo[l/sep].push_back(f); } vector ans1(q); // AC vector ans2(q); // WA vector> ac; ac.resize(m); vector lftsum(m); int l = 0, r = 0; int tl, tr; int nowans1 = 0; int nowans2 = 0; for(int i=0; i=tr; k--){ if (dat[k] == 1){ ac[prob[k]].pop_back(); if (ac[prob[k]].empty()){ nowans2 -= lftwa[ac[prob[k]].front()] - lftsum[prob[k]]; nowans1--; } } } //左を縮ませる for(int k=l; k=tl; k--){ if (dat[k] == 1){ if (!ac[prob[k]].empty()){ nowans2 -= lftwa[ac[prob[k]].front()] - lftsum[prob[k]]; }else{ nowans1++; } ac[prob[k]].push_front(k); }else{ lftsum[prob[k]]--; if (!ac[prob[k]].empty()) nowans2++; } } l = tl; r = tr; ans1[mo[i][j].index] = nowans1; ans2[mo[i][j].index] = nowans2; } } for(int i=0; i