#include <cstdint> #include <cstdio> #include <vector> using namespace std; using i64 = int64_t; template <class T> struct SegTree { int N; vector<T> dat; explicit SegTree(int n) { N = 1; while(N < n) { N <<= 1; } N <<= 1; dat.assign(N, 0); } void update(int a, int b, int k, int l, int r, int x) { if(k >= N) { return; } if(dat[k] != 0) { return; } if(b <= l || r <= a) { return; } update(a, b, 2*k+0, l, (l+r)/2, x); update(a, b, 2*k+1, (l+r)/2, r, x); if(a <= l && r <= b) { if(l+1 == r || (dat[2*k] == x && dat[2*k+1] == x)) { dat[k] = x; } } } void update(int a, int b, int x) { update(a, b, 1, 0, N/2, x); } void dump() { for(int i=0; i<N; ++i) { if(i) { fprintf(stderr, " "); } fprintf(stderr, "%d", dat[i]); } fprintf(stderr, "\n"); } void solve() { vector<int> v(4); for(int i=N/2; i<N; ++i) { ++v[dat[i]]; } printf("%d %d %d\n", v[1], v[2], v[3]); } }; int main(void) { int N, M; scanf("%d%d", &N, &M); SegTree<int> tree(N); for(int i=0; i<M; ++i) { int a, b; char c; scanf("%d %d %c", &a, &b, &c); int x = 1; switch(c) { case 'K': x = 2; break; case 'C': x = 3; break; } --a; tree.update(a, b, x); } tree.solve(); return 0; }