while true
  tpr = gets.split.map{|i| i.to_i}
  break if tpr == [0]*3
  
  wrng = Array.new(tpr[0]).map{Array.new(tpr[1],0)}
  crct = Array.new(tpr[0]).map{Array.new(tpr[1],0)}
  
  tpr[2].times{
    lo = gets.split
    if lo[3] == "WRONG"
      lo.map!{|i| i.to_i}
      wrng[lo[0]-1][lo[1]-1] += 1
    elsif lo[3] == "CORRECT"
      lo.map!{|i| i.to_i}
      crct[lo[0]-1][lo[1]-1] = wrng[lo[0]-1][lo[1]-1]*1200 + lo[2]
      wrng[lo[0]-1][lo[1]-1] = -1
    end
  }

  crct.map!{|a| a.inject(:+)}
  wrng.map!{|a| a.count(-1)}
  rslt = []
  for x in 0...tpr[0]
    rslt += [[x+1, wrng[x], crct[x]]]
  end
  rslt.sort_by!{|a| a[2]}.reverse!.sort_by!{|a| a[1]}.reverse!

  for x in rslt
    puts x.join(" ")
  end
end