#define _USE_MATH_DEFINES #include using namespace std; //template #define rep(i,a,b) for(int i=(a);i<(b);i++) #define rrep(i,a,b) for(int i=(a);i>(b);i--) #define ALL(v) (v).begin(),(v).end() typedef long long int ll; const int inf = 0x3fffffff; const ll INF = 0x3fffffffffffffff; template inline bool chmax(T& a,T b){ if(a inline bool chmin(T& a,T b){ if(a>b){a=b;return 1;}return 0; } //template end int a[200010]={},r[200010],col[200010]; vector st[200010]; int main(){ int n,m; scanf("%d%d",&n,&m); rep(i,0,m){ int l; scanf("%d%d",&l,&r[i]); l--; char c; cin>>c; if(c=='Y')col[i]=1; if(c=='K')col[i]=2; if(c=='C')col[i]=3; st[l].push_back(i); } priority_queue,greater> pq; rep(i,0,n){ for(int j:st[i])pq.push(j); while(pq.size()){ int j=pq.top(); if(r[j]<=i){pq.pop(); continue;} a[i]=col[j]; break; } } int ans[3]={}; rep(i,0,n)if(a[i])ans[a[i]-1]++; rep(i,0,3)printf("%d\n",ans[i]); return 0; }