#include #include using namespace std; template struct X { using U = struct { int t; A v; }; U xs[S<<1] = {}; int time = 0; size_t size() { return S; } void update(size_t lp, size_t rp, A v) { time++; _update(0, S>>1, lp, rp, v); } void _update(size_t d, size_t p, size_t lp, size_t rp, A v) { if (p == 0 || rp-lp+1 == (p<<1)) { xs[d].t = time; xs[d].v = v; return; } if ((rp&p)==0) { _update((d<<1)+1, p>>1, lp, rp, v); } else if ((lp&p)!=0) { _update((d<<1)+2, p>>1, p^lp, p^rp, v); } else { _update((d<<1)+1, p>>1, lp, p-1, v); _update((d<<1)+2, p>>1, 0, p^rp, v); } } A get(size_t i) { size_t d = 0; for (size_t p=S>>1, z; p!=0; p >>= 1) { z = d; if ((i&p)==0) { d=(d<<1)+1; } else { d=(d<<1)+2; i^=p; } if (xs[d].t < xs[z].t) { xs[d].t = xs[z].t; xs[d].v = xs[z].v; } } return xs[d].v; } }; using XX = X; using D = struct { int lp, rp; char x; }; XX x; int main() { int n, m; cin >> n >> m; vector vs(m); for (auto &v : vs) { cin >> v.lp >> v.rp >> v.x; } for (int i = m-1; i>=0; i--) { auto &v = vs[i]; x.update(v.lp, v.rp, v.x); } int yc = 0, kc = 0, cc = 0; for (int i = 1; i <= n; i++) { switch (x.get(i)) { case 'Y': yc++; break; case 'K': kc++; break; case 'C': cc++; break; } } cout << yc << " " << kc << " " << cc << endl; return 0; }