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