#include using namespace std; int main () { int N, M, Q; cin >> N >> M >> Q; std::vector> A(M); int ac = 0, wa = 0; for (auto& a : A) { a.push_front(0); } vector P(N), X(N); for (int i = 0; i < N; i ++) { int a; string s; cin >> a >> s; P[i] = --a; X[i] = (s == "AC"); } int bk = sqrt(N); bk = max(1, bk); using T = tuple; vector qu(Q); for (int i =0 ; i < Q; i ++) { int l, r; cin >> l >> r; qu[i] = T{--l, r, i}; } sort(qu.begin(), qu.end(), [&](T a, T b) { auto& [la, ra, ia] = a; auto& [lb, rb, ib] = b; if (la / bk != lb / bk) { return la / bk < lb / bk; } else { return ra < rb; } }); using pr = pair; vector ans(Q); int lnow = 0, rnow = 0; for (auto [l, r, i] : qu) { while (rnow < r) { int p = P[rnow]; if (X[rnow]) { if (A[p].size() == 1) { wa += A[p].front(); ac ++; } // A[p].push_front(-1); A[p].push_front(0); } else { int x = A[p].front(); A[p].pop_front(); A[p].push_front(++x); } rnow ++; } while (lnow > l) { lnow --; int p = P[lnow]; if (X[lnow]) { if (A[p].size() != 1) { int x = A[p].back(); wa -= x; } else { ac ++; } // A[p].push_back(-1); A[p].push_back(0); } else { if (A[p].size() != 1) { wa ++; } int x = A[p].back(); A[p].pop_back(); A[p].push_back(++x); } } while (lnow < l) { int p = P[lnow]; if (X[lnow]) { // A[p].pop_back(); A[p].pop_back(); if (A[p].size() == 1) { ac --; } else { wa += A[p].back(); } } else { if (A[p].size() > 1) { wa --; } int x = A[p].back(); A[p].pop_back(); A[p].push_back(--x); } lnow ++; } while (rnow > r) { rnow --; int p = P[rnow]; if (X[rnow]) { // A[p].pop_front(); A[p].pop_front(); if (A[p].size() == 1) { ac --; wa -= A[p].front(); } } else { int x = A[p].front(); A[p].pop_front(); A[p].push_front(--x); } } ans[i] = pr{ac, wa}; } for (auto [a, c] : ans) { printf("%d %d\n", a, c); } }