N, K, Q = gets.split.map(&:to_i) query_list = Q.times.map { gets.chomp.split } counter = Hash.new(0) row_c = 0 col_c = 0 row_visited = Hash.new(false) col_visited = Hash.new(false) query_list.reverse_each do |a, b, c| b = b.to_i c = c.to_i next if row_visited[b] && a == 'R' next if col_visited[b] && a == 'C' if a == 'C' counter[c] += N - row_c if c != 1 col_visited[b] = true col_c += 1 else counter[c] += N - col_c if c != 1 row_visited[b] = true row_c += 1 end end counter[1] = N * N - counter.values.sum puts (1..K).map { |c| counter[c] }