import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] first = br.readLine().split(" ", 2); Scanner sc = new Scanner(System.in); int n = Integer.parseInt(first[0]); int m = Integer.parseInt(first[1]); Order[] leftArr = new Order[m]; Order[] rightArr = new Order[m]; for (int i = 0; i < m; i++) { String[] line = br.readLine().split(" ", 3); Order or = new Order(i, Integer.parseInt(line[0]), Integer.parseInt(line[1]), line[2].charAt(0)); leftArr[i] = or; rightArr[i] = or; } Arrays.sort(leftArr, new Comparator() { public int compare(Order o1, Order o2) { return o1.left - o2.left; } }); Arrays.sort(rightArr, new Comparator() { public int compare(Order o1, Order o2) { return o1.right - o2.right; } }); TreeSet set = new TreeSet(new Comparator() { public int compare(Order o1, Order o2) { return o1.idx - o2.idx; } }); int[] counts = new int[3]; int leftIdx = 0; int rightIdx = 0; for (int i = 1; i <= n; i++) { while(leftIdx < m && leftArr[leftIdx].left == i) { set.add(leftArr[leftIdx]); leftIdx++; } if (set.size() == 0) { continue; } counts[set.first().type]++; while (rightIdx < m && rightArr[rightIdx].right == i) { set.remove(rightArr[rightIdx]); rightIdx++; } } 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; } } }