Go: // You Are the Judge(審判は君だ！)
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2400&lang=jp
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

type Team struct {
	TID         int
	Accepted    int
	WrongAnswer map[int]int
	Penalty     int
}

type Teams []Team

func (t Teams) Len() int      { return len(t) }
func (t Teams) Swap(i, j int) { t[i], t[j] = t[j], t[i] }
func (t Teams) Less(i, j int) bool {
	// より多くの問題を解いたチームは順位が上になる
	if t[i].Accepted > t[j].Accepted {
		return true
	} else if t[i].Accepted == t[j].Accepted {
		// 解いた問題が同じ場合、ペナルティの少ないチームのほうが順位が上になる
		if t[i].Penalty < t[j].Penalty {
			return true
		} else if t[i].Penalty == t[j].Penalty {
			// 解いた問題もペナルティも同じ場合、チーム番号が小さいほうのチームが順位が上になる
			if t[i].TID < t[j].TID {
				return true
			}
		}
	}
	return false
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	for {
		t, p, r := nextInt(sc), nextInt(sc), nextInt(sc)
		if t == 0 && p == 0 && r == 0 {
			break
		}

		teams := []Team{}
		for tID := 0; tID < t; tID++ {
			teams = append(teams, Team{tID + 1, 0, map[int]int{}, 0})
		}

		for i := 0; i < r; i++ {
			tID, pID, time, message := nextInt(sc), nextInt(sc), nextInt(sc), nextString(sc)
			tID--

			if message == "CORRECT" {
				teams[tID].Accepted++
				wa, _ := teams[tID].WrongAnswer[pID]
				teams[tID].Penalty += wa*1200 + time
			} else {
				teams[tID].WrongAnswer[pID]++
			}
		}

		sort.Sort(Teams(teams))

		for _, team := range teams {
			fmt.Println(team.TID, team.Accepted, team.Penalty)
		}
	}
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func nextString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

C++: #include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <stack>
#include <deque>
#include <queue>
#include <set>
#include <cmath>
#include <algorithm>
#include <map>
#include <list>
#include <cstdlib>

using namespace std;

typedef pair<pair<int, int>, int> P;
#define T_MAX 64
#define P_MAX 16

map<vector<int>, int> cost;

class C_Team{
private :
	int penalty;
	int correct;
	int wrong[P_MAX];
public :
	C_Team();
	void Submit(int time, int pID, bool result);
	int GetCorrect() { return correct; }
	int GetPenalty() { return penalty; }
};

int main()
{
	while(1) {
		// <<正答数, ペナルティ>, ID>
		pair<pair<int, int>, int> info[T_MAX];
		C_Team team[T_MAX];
		int t, p, r;
		cin >> t >> p >> r;
		if(!t && !p && !r) break;
		for(int i = 0; i < r; i++) {
			int tid, pid, time;
			string message;
			cin >> tid >> pid >> time >> message;
			team[tid].Submit(time, pid, message == "CORRECT");
		}
	
		for(int i = 1; i <= t; i++) {
			info[i].first.first = -team[i].GetCorrect(); // sortは昇順なのでマイナス
			info[i].first.second = team[i].GetPenalty();
			info[i].second = i;
		}

		sort(info+1, info+t+1);
		for(int i = 1; i <= t; i++) {
			cout << info[i].second << " " << -info[i].first.first << " " << info[i].first.second << endl;
		}
	}
	return 0;
}

C_Team::C_Team() {
	correct = 0;
	penalty = 0;
	for(int i = 0; i < P_MAX; i++) {
		wrong[i] = 0;
	}
}

void C_Team::Submit(int time, int pID, bool result) {
	if(result) {
		correct++;
		penalty += wrong[pID] * 1200 + time;
	} else {
		wrong[pID]++;
	}
}

C++: //
//  main.cpp
//  c
//
//  Created by 13B10694 on 2015/06/01.
//  Copyright (c) 2015????´ 13B10694. All rights reserved.
//

#include <iostream>
#include <vector>
#include<stdio.h>
#include <algorithm>
#include<string.h>
using namespace std;

int now=1;

class team{
    
public:
    int id, pen, sol;
    int wrong[12];
    vector <int> solved;
    team(){
        memset(wrong, 0, sizeof(wrong));
        id=now++;
       // pen=0;sol=0;
    }
//    ~team(){
//        solved.clear();
//    }
    
    bool operator < (const team& b) const
    {
        return solved.size()==b.solved.size() ? pen== b.pen ? id<b.id : pen<b.pen : solved.size()>b.solved.size();
    }
};

int main() {
    int t,p,r;
    while(cin>>t>>p>>r,t){
        now=1;
        vector<team> tea(t);

        for(int i=0;i<r;i++){
            int ti, pi, tim;
            string mes;
            cin>>ti>>pi>>tim>>mes;
            ti-=1;
            if(mes=="WRONG"){
                tea[ti].wrong[pi]++;
                continue;
            }
            if(find(tea[ti].solved.begin(),tea[ti].solved.end(),pi)!=tea[ti].solved.end()){
                continue;
            }
            tea[ti].solved.push_back(pi);
            tea[ti].pen += tea[ti].wrong[pi]*1200+tim;
  
        }
        sort(tea.begin(),tea.end());
        for(int i=0;i<t;i++){
            cout<<tea[i].id<<" "<<tea[i].solved.size()<<" "<<tea[i].pen<<endl;
        }
       // tea.clear();
    }
    
    return 0;
}

C++: #include <iostream>
#include <string>

using namespace std;

class team_obj{
	public:
	int ansNum;
	int penalty;
	int wrongNum[10];
	int teamNum;
};

void swap(int *a,int *b){
	int tmp = *a;
	*a = *b;
	*b = tmp;
}

int main(){

	team_obj team[50];
	int ansLine[20];

	for(int i=0;i<50;i++){
		team[i].ansNum=0;
		team[i].penalty=0;
		for(int j=0;j<10;j++){
			team[i].wrongNum[j]=0;
		}
		team[i].teamNum=i;
	}

	int t,p,r;
	while(cin>>t>>p>>r){
		if(t==0 && p==0 && r==0)break;
			
		int tid,pid,time;
		string str;
		for(int i=0;i<50;i++){
			team[i].ansNum=0;
			team[i].penalty=0;
			for(int j=0;j<10;j++){
				team[i].wrongNum[j]=0;
			}
			team[i].teamNum=i;
		}
		for(int i=0;i<20;i++)ansLine[i]=0;

		for(int i=0;i<r;i++){
			cin>>tid>>pid>>time>>str;

			tid--;
			pid--;

			if(team[tid].wrongNum[pid]==-1)continue;

			if(str=="WRONG"){
				team[tid].wrongNum[pid]++;
			}
			else{
				team[tid].penalty+=team[tid].wrongNum[pid]*1200+time;
				team[tid].wrongNum[pid]=-1;
				team[tid].ansNum++;
			}
		}
/*
		for(int i=0;i<t;i++){
			cout<<"i="<<i<<endl;
			cout<<team[i].ansNum<<" "<<team[i].penalty<<endl;
		}
		*/
		//答え数のソートを行う。
		for(int i=0;i<t;i++){
			for(int j=t-1;j>i;j--){
				if(team[j].ansNum>=team[j-1].ansNum){
					int tmp = team[j].ansNum;
					team[j].ansNum = team[j-1].ansNum;
					team[j-1].ansNum =tmp;
					
					tmp = team[j].penalty;
					team[j].penalty = team[j-1].penalty;
					team[j-1].penalty = tmp;

					tmp = team[j].teamNum;
					team[j].teamNum = team[j-1].teamNum;
					team[j-1].teamNum = tmp;
				}
			}
		}
		//答え数の数を数える。
		for(int i=0;i<t;i++){
			ansLine[team[i].ansNum]++;
		}

		//次はペナルティにてソートを行う。
		//ペナルティにてソートを行う際、回答数が同じ場合のみ交換を行う。
		for(int i=0;i<t;i++){
			for(int j=t-1;j>i;j--){
				if(team[j].penalty<=team[j-1].penalty && team[j].ansNum == team[j-1].ansNum){
					int tmp = team[j].ansNum;
					team[j].ansNum = team[j-1].ansNum;
					team[j-1].ansNum =tmp;
					
					tmp = team[j].penalty;
					team[j].penalty = team[j-1].penalty;
					team[j-1].penalty = tmp;

					tmp = team[j].teamNum;
					team[j].teamNum = team[j-1].teamNum;
					team[j-1].teamNum = tmp;
				}
			}
		}
		//最後にチーム番号にてソートを行う。
		//回答数とペナルティ数が同じ場合のみソートを実行
		for(int i=0;i<t;i++){
			for(int j=t-1;j>i;j--){
				if(team[j].teamNum<=team[j-1].teamNum && team[j].ansNum == team[j-1].ansNum && team[j].penalty == team[j-1].penalty){
					int tmp = team[j].ansNum;
					team[j].ansNum = team[j-1].ansNum;
					team[j-1].ansNum =tmp;
					
					tmp = team[j].penalty;
					team[j].penalty = team[j-1].penalty;
					team[j-1].penalty = tmp;

					tmp = team[j].teamNum;
					team[j].teamNum = team[j-1].teamNum;
					team[j-1].teamNum = tmp;
				}
			}
		}

		//解答出力
		for(int i=0;i<t;i++){
			team[i].teamNum++;
			cout<<team[i].teamNum<<" "<<team[i].ansNum<<" "<<team[i].penalty<<endl;
		}


	}

	return 0;
}