class Team
    def initialize(id)
        @id = id
        @stat = Hash.new(0)
    end
    attr_reader :id

    def miss(pid)
        @stat[pid] -= 1
    end

    def success(pid, time)
        @stat[pid] = time - @stat[pid] * 1200
    end

    def finished(pid)
        @stat[pid] > 0
    end

    def penalty
        @stat.values.select {|x| x > 0}
    end

    def solved_num
        penalty.size
    end

    def penalty_sum
        penalty.inject(:+) || 0
    end

    def score
        [- solved_num, penalty_sum, id]
    end
end

loop do
    team_num, prob_num, log_num = gets.split.map(&:to_i)
    break if team_num == 0
    teams = (0..team_num).map {|i| Team.new(i)}
    log_num.times do
        a = gets.chomp.split
        message = a.pop
        tid, pid, time = a.map(&:to_i)
        team = teams[tid]
        next if team.finished(pid)
        if message == 'WRONG'
            team.miss(pid)
        else
            team.success(pid, time)
        end
    end
    teams.shift
    teams.sort_by(&:score).each do |team|
        puts [team.id, team.solved_num, team.penalty_sum] * ' '
    end
end