#pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #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(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); int n, m, q; cin >> n >> m >> q; vector prob(n); vector dat(n); vector lftwa(n); 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 lpiv(m); vector rpiv(m); vector lftsum(m); int l = 0, r = 0; int tl, tr, daime; int nowans1 = 0; int nowans2 = 0; for(int i=0; i=tr; k--){ daime = prob[k]; if (dat[k] == 1){ rpiv[daime]--; if (lpiv[daime] == rpiv[daime]){ nowans1--; nowans2 -= lftwa[k] - lftsum[daime]; } } } //左を縮ませる for(int k=l; k=tl; k--){ daime = prob[k]; if (dat[k] == 1){ if (lpiv[daime] != rpiv[daime]){ nowans2 -= lftwa[lpiv[daime]] - lftsum[daime]; }else{ nowans1++; } lpiv[daime]--; }else{ lftsum[daime]--; if (lpiv[daime] != rpiv[daime]) nowans2++; } } l = tl; r = tr; ans1[mo[i][j].index] = nowans1; ans2[mo[i][j].index] = nowans2; } } for(int i=0; i