import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); PriorityQueue leftQueue = new PriorityQueue(new Comparator() { public int compare(Order o1, Order o2) { return o1.left - o2.left; } }); PriorityQueue rightQueue = new PriorityQueue(new Comparator() { public int compare(Order o1, Order o2) { return o1.right - o2.right; } }); for (int i = 0; i < m; i++) { Order or = new Order(i, sc.nextInt(), sc.nextInt(), sc.next().charAt(0)); leftQueue.add(or); rightQueue.add(or); } TreeSet set = new TreeSet(new Comparator() { public int compare(Order o1, Order o2) { return o1.idx - o2.idx; } }); int[] counts = new int[3]; for (int i = 1; i <= n; i++) { while (leftQueue.size() > 0 && leftQueue.peek().left == i) { set.add(leftQueue.poll()); } if (set.size() == 0) { continue; } counts[set.first().type]++; while (rightQueue.size() > 0 && rightQueue.peek().right == i) { set.remove(rightQueue.poll()); } } System.out.print(counts[0] + " " + counts[1] + " " + counts[2]); } static class Order { int idx; int left; int right; int type; public Order (int idx, int left, int right, char typeC) { this.idx = idx; this.left = left; this.right = right; if (typeC == 'Y') { type = 0; } else if (typeC == 'K') { type = 1; } else { type = 2; } } public int hashCode() { return idx; } public boolean equals(Object o) { Order or = (Order) o; return idx == or.idx; } } }