#if __INCLUDE_LEVEL__ == 0 #include using namespace std; #undef assert #define assert(expr) (expr) || (__builtin_unreachable(), 0) #include __BASE_FILE__ namespace std::ranges::views { namespace { void solve() { int n, m, q; cin >> tie(n, m, q); vector p(n); vector s(n); for (int i : iota(0, n)) { cin >> tie(p[i], s[i]); --p[i]; } vector l(q), r(q); for (int id : iota(0, q)) { cin >> tie(l[id], r[id]); --l[id]; } vector> lst(m); for (int i : iota(0, n)) { lst[p[i]].push_back(i); } vector> ans(q); vector> ids(m); for (int id : iota(0, q)) { ids[l[id]].push_back(id); } atcoder::fenwick_tree f_ac(n); atcoder::fenwick_tree f_wa(n); for (int x : iota(0, m)) { bool ac = false; for (int i : lst[x]) { ac |= s[i] == "AC"; } if (!ac) { continue; } for (int i : lst[x]) { if (s[i] == "AC") { f_ac.add(i, 1); break; } else { f_wa.add(i, 1); } } } for (int L : iota(0, n)) { for (int id : ids[L]) { ans[id] = {f_ac.sum(l[id], r[id]), f_wa.sum(l[id], r[id])}; } if (s[L] == "AC") { bool ac = false; for (auto it = upper_bound(lst[p[L]], L); it != lst[p[L]].end(); ++it) { ac |= s[*it] == "AC"; } if (ac) { for (auto it = upper_bound(lst[p[L]], L); it != lst[p[L]].end(); ++it) { if (s[*it] == "AC") { f_ac.add(*it, 1); break; } else { f_wa.add(*it, 1); } } } } } for (auto e : ans) { cout << e << '\n'; } } } // namespace } // namespace std::ranges::views using views::solve; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); solve(); } #else // __INCLUDE_LEVEL__ #include namespace std { template istream& operator>>(istream& is, pair& p) { return is >> p.first >> p.second; } template istream& operator>>(istream& is, tuple& t) { return apply([&is](auto&... xs) -> istream& { return (is >> ... >> xs); }, t); } template istream& operator>>(istream& is, tuple&& t) { return is >> t; } template >* = nullptr> auto operator>>(istream& is, R&& r) -> decltype(is >> *begin(r)) { for (auto&& e : r) { is >> e; } return is; } template ostream& operator<<(ostream& os, const pair& p) { return os << p.first << ' ' << p.second; } template ostream& operator<<(ostream& os, const tuple& t) { auto f = [&os](const auto&... xs) -> ostream& { [[maybe_unused]] auto sep = ""; ((os << exchange(sep, " ") << xs), ...); return os; }; return apply(f, t); } template >* = nullptr> auto operator<<(ostream& os, R&& r) -> decltype(os << *begin(r)) { auto sep = ""; for (auto&& e : r) { os << exchange(sep, " ") << e; } return os; } } // namespace std #endif // __INCLUDE_LEVEL__