def readl $stdin.gets.split(" ") end N,K,Q = readl.map{ |r| r.to_i } rows = (0...N).map{ [-1,1] } cols = (0...N).map{ [-2,1] } #p rows #p cols Q.times do |i| a,b,c = readl b = b.to_i c = c.to_i colorpair = [i,c] case a when "R" rows[b-1] = colorpair when "C" cols[b-1] = colorpair end end #p rows #p cols rows = rows.sort{ |a,b| a[0] <=> b[0] } cols = cols.sort{ |a,b| a[0] <=> b[0] } #p rows #p cols def count_wins(item, arr) i = item[0] color = item[1] # b-search mi,ma = 0,arr.size-1 j = (mi+ma)/2 if i