using System;
using System.Collections.Generic;
using System.Linq;

namespace Volume24_2400
{
    class Program
    {
        public static void Main(string[] args)
        {
            while (true)
            {
                var input = Console.ReadLine().Split(' ');
                var teamCount = Convert.ToInt32(input[0]);
                var programCount = Convert.ToInt32(input[1]);
                var recordCount = Convert.ToInt32(input[2]);

                if (teamCount == 0 && programCount == 0 && recordCount == 0) break;

                var entries = new List<Team>(teamCount);

                // Initialize
                Enumerable
                    .Range(0, teamCount)
                    .All(i =>
                    {
                        var team = new Team(i + 1);
                        team.Success = new int[programCount];
                        team.Wrong = new int[programCount];

                        entries.Add(team);
                        return true;
                    });

                // Comparer
                Enumerable
                    .Range(0, recordCount)
                    .All(i =>
                    {
                        input = Console.ReadLine().Split(' ');
                        var teamID = Convert.ToInt32(input[0]);
                        var programID = Convert.ToInt32(input[1]);
                        var time = Convert.ToInt32(input[2]);
                        var message = input[3];

                        var team = entries.Find(t => t.ID == teamID);
                        
                        if (team.Success[programID - 1] == 1) return true;

                        switch (message)
                        {
                            case "WRONG":
                                team.Wrong[programID - 1]++;
                                break;
                            case "CORRECT":
                                team.Penalty += team.Wrong[programID - 1] * 1200 + time;
                                team.Success[programID - 1] = 1;

                                break;
                            default:
                                throw new Exception();
                        }
                        return true;
                    });

                // Sort
                entries.Sort();

                // Write Out
                foreach (var team in entries)
                {
                    Console.WriteLine(team.ID + " " + team.Success.Sum() + " " + team.Penalty);
                }
            }
        }
    }

    public class Team : IComparable<Team>
    {
        public int ID { get; protected set; }
        public int[] Success { get; set; }
        public int[] Wrong { get; set; }
        public int Penalty { get; set; }

        public Team(int id)
        {
            ID = id;
        }

        public int CompareTo(Team other)
        {
            if (other == null) return -1;

            var mySuccessTotal = Success.Sum();
            var otherSuccessTotal = other.Success.Sum();

            if (mySuccessTotal > otherSuccessTotal) return -1;
            if (mySuccessTotal < otherSuccessTotal) return 1;

            if (mySuccessTotal == otherSuccessTotal)
            {
                if (Penalty < other.Penalty) return -1;
                if (Penalty > other.Penalty) return 1;

                if (Penalty == other.Penalty)
                {
                    if (ID < other.ID) return -1;
                    if (ID > other.ID) return 1;
                    if (ID == other.ID) return 0;
                }
            }

            throw new Exception();
        }
    }
}

Measured memory_bytes: 10088