using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

using CHY72;

namespace CHY72{
    
    public class PointXY<T>where T:IComparable  {
        public T X , Y;
        public bool Flag = false;
        public PointXY(T _X,T _Y) {
            X = _X; Y = _Y;
        }
        public static bool operator ==(PointXY<T> P1, PointXY<T> P2) {
            return (P1.X.CompareTo( P2.X) == 0 && P1.Y.CompareTo (P2.Y) == 0);
        }
        public static bool operator !=(PointXY<T> P1, PointXY<T> P2) {return !(P1 ==P2);}
        public override int GetHashCode() {return X.GetHashCode() ^ Y.GetHashCode();}
        public override bool Equals(object obj) {
            if (obj == null || this.GetType() != obj.GetType()) {return false;}
            return (this == (PointXY<T>)obj);
        }
        //char '0' == int 48 ;....;char '9' == int 57;

    }

    public class Lib72 {
        public static int NumFromChar(char CNUM) { return CNUM - 48; }

        public static int[] KETAArray(int Num) {return KETAArray(Num.ToString()); }
        public static int[] KETAArray(string Num) {
            char[] cKETA = Num.ToCharArray();
            int[] iKETA = new int[cKETA.Length];
            for (int i = 0; i < iKETA.Length; i++) {
                iKETA[i] = NumFromChar(cKETA[i]);
            }
            return iKETA;
        }
        public static int KETA(int Num) { return Num.ToString().ToCharArray().Length; }
        public static int FromKETAArray(int[] _ketaarray) {
            int result = 0;
            int[] R_ketaarray = _ketaarray.Reverse().ToArray(); 
            for (int i = 0,j=1; i < R_ketaarray.Length; i++,j *=10) {
                result += j * R_ketaarray[i];
            }
            return result;
        }
    }
}    

public class Program {
    static bool ReadLine_1(ref int num1, bool Fin0 = true) {
        string str = Console.ReadLine();
        num1 = int.Parse(str);
        return (Fin0 && num1 == 0);
    }
    static int  ReadLine_1() {
        return  int.Parse(Console.ReadLine());
    }
    static bool ReadLine_2(ref int num1, ref int num2, char Spliter = ' ', bool Fin0 = true) {
        string str = Console.ReadLine();
        num1 = int.Parse(str.Split(Spliter)[0]);
        num2 = int.Parse(str.Split(Spliter)[1]);
        return (Fin0 && num1 == 0 && num2 == 0);
    }
    static int[] ReadLine72(char Spliter = ' ') {
        return Console.ReadLine().Split(Spliter).Select(s => int.Parse(s)).ToArray();
    }

    const int DefaultMax = 72727272;

    
    public class ICPCTEAM{
        public int[] MissNum = new int[1];
        public int CorrectNum = 0;
        public int Penalty = 0;
        public int TeamID ;
        public ICPCTEAM(int _tID,int _ProblemNum){
            TeamID = _tID;
            MissNum = new int [_ProblemNum ];
        }
        public int CulcPENALTY(int _ProblemNum,int TIME) {
            return MissNum[_ProblemNum] *1200 + TIME; 
        }
    
    }

    static void Main(string[] args) {
        while (true) {
            int[] TPR = ReadLine72();
            if (TPR[0] == 0) return;
            //Teams[0],Penalty[0] is Dummy
            ICPCTEAM[] Teams = new ICPCTEAM[TPR[0] + 1];
            Teams[0] = new ICPCTEAM(0, TPR[1] + 1);
            for(int i = 1;i < TPR[0] + 1;i++ ){
                Teams [i] = new ICPCTEAM(i,TPR[1] + 1);
            }
            for (int i = 0; i < TPR[2]; i++) {
                string str = Console.ReadLine();
                int tID =int.Parse (str.Split(' ')[0]);
                int pID = int.Parse(str.Split(' ')[1]);
                int Time = int.Parse(str.Split(' ')[2]);
                bool isCorrect = ("CORRECT" == str.Split(' ')[3]);
                if(isCorrect){
                    Teams[tID].CorrectNum++;
                    Teams[tID].Penalty += Teams[tID].CulcPENALTY(pID,Time );
                }else{
                    Teams[tID].MissNum[pID]++;
                    
                }
            }
            //tID,CorrectNum .penalty
            ICPCTEAM[] OrderedByTeams =  Teams.OrderBy(x => x.Penalty).ToArray().
                                               OrderByDescending(x => x.CorrectNum).ToArray()
                                                ;
            for (int i = 0; i < OrderedByTeams.Length; i++) {
                if (OrderedByTeams[i].TeamID != 0) {
                    Console.WriteLine(OrderedByTeams[i].TeamID + " " + OrderedByTeams[i].CorrectNum + " " + OrderedByTeams[i].Penalty);

                }
            }


        }
    }
}

Measured memory_bytes: 6732