#include #include #include #include #include using namespace std; int main() { int n, m; cin >> n >> m; vector> vs(m); for (int i = 0; i < m; i++) { int l, r; char x; cin >> l >> r >> x; vs[i] = make_tuple(l, -i, r, x); } sort(vs.begin(), vs.end()); priority_queue> pq; int j = 0; int yc = 0, kc = 0, cc = 0; for (int i = 1; i <= n; i++) { while (j < m && i == get<0>(vs[j])) { pq.push(make_tuple(get<1>(vs[j]), get<2>(vs[j]), get<3>(vs[j]))); j++; } while (!pq.empty() && get<1>(pq.top()) < i) { pq.pop(); } if (pq.empty()) { continue; } switch (get<2>(pq.top())) { case 'Y': yc++; break; case 'K': kc++; break; case 'C': cc++; break; } } cout << yc << " " << kc << " " << cc << endl; return 0; }