#include #include #include using namespace std; int main(){ int N,M; cin >> N >> M; vector L(M), R(M); vector T(M); for (int i = 0; i < M; i++){ cin >> L[i] >> R[i] >> T[i]; L[i]--; } vector>> d(N + 1); for (int i = 0; i < M; i++){ d[L[i]].push_back(make_pair(i, T[i])); d[R[i]].push_back(make_pair(i, T[i])); } int Y = 0, K = 0, C = 0; set> st; for (int i = 0; i < N; i++){ int cnt = d[i].size(); for (int j = 0; j < cnt; j++){ if (!st.count(d[i][j])){ st.insert(d[i][j]); } else { st.erase(d[i][j]); } } if (!st.empty()){ char ch = (*st.begin()).second; if (ch == 'Y'){ Y++; } if (ch == 'K'){ K++; } if (ch == 'C'){ C++; } } } cout << Y << ' ' << K << ' ' << C << endl; }