def main(): import sys input = sys.stdin.readline class Bit: def __init__(self, n): self.size = n self.tree = [0] * (n + 1) def sum(self, i): s = 0 while i > 0: s += self.tree[i] i -= i & -i return s def add(self, i, x): while i <= self.size: self.tree[i] += x i += i & -i def lower_bound(self, w): if w <= 0: return 0 x = 0 k = 1 << (self.size.bit_length() - 1) while k: if x + k <= self.size and self.tree[x + k] < w: w -= self.tree[x + k] x += k k >>= 1 return x+1 N, M = map(int, input().split()) q = [] qy = [0] * (M+1) ans = [0] * 3 bit = Bit(M) for i in range(1, M+1): s, t, y = input().split() s = int(s) t = int(t) if y == 'K': qy[i] = 1 elif y == 'C': qy[i] = 2 q.append((s, 1, i)) if t+1 <= N: q.append((t+1, -1, i)) q.sort(key=lambda x: x[0]) i = 1 for t, flg, j in q: while i < t: k = bit.lower_bound(1) if k != M + 1: ans[qy[k]] += 1 i += 1 bit.add(j, flg) while i < N+1: k = bit.lower_bound(1) if k != M + 1: ans[qy[k]] += 1 i += 1 print(*ans) if __name__ == '__main__': main()