#include #include using namespace std; using namespace atcoder; using ll = long long; constexpr ll mod = 1e9 + 7; constexpr ll INF = 1LL << 60; #define REP(i, init, n) for(int i = (int)(init); i < (int)(n); i++) #define All(A) A.begin(), A.end() #define rAll(A) A.rbegin(), A.rend() #define vi vector #define vl vector #define vvi vector> #define vvl vector> #define pint pair #define plong pair int N, M; vvi Q; void solve() { vi ans(N, -1); reverse(All(Q)); vector A(N); REP(i, 0, M) { int l = Q[i][0], r = Q[i][1], c = Q[i][2]; A[l].push_back({i, r, c}); } priority_queue P; REP(i, 0, N) { for(vi a: A[i]) { P.push(a); // cout << "pushed: " << a[0] << " " << a[1] << " " << a[2] << endl; } vi top = P.top(); int priority = top[0], r = top[1], c = top[2]; // cout << priority << " " << r << " " << c << endl; while(r < i) { P.pop(); if(P.empty()) { c = -1; break; } top = P.top(); priority = top[0], r = top[1], c = top[2]; } ans[i] = c; /* REP(i, 0, N) cout << ans[i] << " "; cout << endl; */ } vi cnt(3, 0); REP(i, 0, N) { if(ans[i] == -1) continue; cnt[ans[i]]++; } REP(i, 0, 3) { cout << cnt[i] << " "; } cout << endl; } int main() { cin >> N >> M; Q.resize(M); REP(i, 0, M) { int l, r; char t; cin >> l >> r >> t; l--; r--; int c = 0; if(t == 'K') c = 1; if(t == 'C') c = 2; Q[i] = {l, r, c}; } solve(); }