def readl $stdin.gets.split(" ") end N,K,Q = readl.map{ |r| r.to_i } rd = {} cd = {} color_count = (0...K).map{ 0 } (0...Q).map{ |i| [i, *(readl)] }.reverse.each{ |l| i,a,b,c = l b = b.to_i c = c.to_i case a when "R" next if rd.key?(b) color_count[c-1] += N - cd.size rd[b] = 1 when "C" next if cd.key?(b) color_count[c-1] += N - rd.size cd[b] = 1 end } color_count[0] += (N - rd.size)*(N - cd.size) puts color_count