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++: #define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>

using namespace std;

typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;

int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};

static const double EPS = 1e-8;

class Data{
public:
	int wrong[11];
	bool correct[11];
	int penalty;
	Data(){
		memset(wrong,0,sizeof(wrong));
		memset(correct,0,sizeof(correct));
		penalty = 0;
	}
};

class Team{
public:
	int solved;
	int penalty;
	int tid;
	Team (int _sol,int _pen,int _tid) : solved(_sol),penalty(_pen),tid(_tid) {}
	bool operator<(const Team& t) const{
		if(solved != t.solved){
			return solved > t.solved;
		}
		else if(solved == t.solved && penalty != t.penalty){
			return penalty < t.penalty;
		}
		else{
			return tid < t.tid;
		}
	}
};

int main(){
	int T,P,R;
	while(~scanf("%d %d %d",&T,&P,&R)){
		if(T==0 && P==0 && R==0) break;
		map<int,Data> status;
		for(int i=1;i<=T;i++){
			status[i];
		}
		for(int i=0;i<R;i++){
			int tID;
			int pID;
			int time;
			string str;
			cin >> tID >> pID >> time >> str;
			if(str == "CORRECT"){
				status[tID].correct[pID] = true;
				status[tID].penalty += status[tID].wrong[pID] * 1200 + time; 
			}
			else{
				if(!status[tID].correct[pID]) status[tID].wrong[pID]++;
			}
		}

		vector<Team> teams;

		for(map<int,Data>::iterator it = status.begin(); it != status.end(); it++){
			teams.push_back(Team(count(it->second.correct,it->second.correct + 11,true),it->second.penalty,it->first));
		}

		sort(teams.begin(),teams.end());

		for(int i=0;i<teams.size();i++){
			printf("%d %d %d\n",teams[i].tid,teams[i].solved,teams[i].penalty);
		}
	}
}

C++: #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <cstring>
#include <cctype>
#include <sstream>
#include <set>
#include <map>
#include <queue>
#include <complex>
using namespace std;
#define REP(i,n) for(int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for(int i = a; i < (int)b; i++)
const int INF = 1<<28;

bool com(const pair<int, pair<int, int> >& left, const pair<int, pair<int, int> >& right) {
    if(left.second.first == right.second.first) {
        if(left.second.second == right.second.first)
            return left.first < right.first;
        else
            return left.second.second < right.second.second;
    }
    else
        return left.second.first > right.second.first;
}

int main() {
    int T, P, R;
    while(cin >> T >> P >> R, T|P|R) {
        vector< pair<int, pair<int, int> > > vp;
        multiset<int> w;
        REP(i, T)
        vp.push_back(make_pair(i+1, make_pair(0, 0)));
        REP(j, R) {
            int tid, pid, time;
            string message;
            cin >> tid >> pid >> time >> message;
            if(message == "CORRECT") {
                vp[tid-1].second.first++;
                vp[tid-1].second.second += w.count(tid * 100 + pid) * 1200 + time;
            }
            else if(message == "WRONG")
                w.insert(tid * 100 + pid);
        }
        sort(vp.begin(), vp.end(), com);
        REP(i, vp.size())
        cout << vp[i].first << ' ' << vp[i].second.first << ' ' << vp[i].second.second << endl; 
    }
    return 0;
}

C++: #include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
	int t,p,r;
	while(cin>>t>>p>>r){
		if(t==0&&p==0&&r==0) break;
		int tid,pid,time,wa[t+1][p+1],ac[t+1],pen[t+1];
		for(int i=0;i<=t;i++){
			pen[i]=0;
			ac[i]=0;
			for(int j=0;j<=p;j++){
				wa[i][j]=0;
			}
		}
		string m;
		for(int i=0;i<r;i++){
			cin>>tid>>pid>>time>>m;
			if(m=="WRONG"){
				wa[tid][pid]++;
			}
			else if(m=="CORRECT"){
				ac[tid]++;
				pen[tid]=pen[tid]+wa[tid][pid]*1200+time;
				wa[tid][pid]=0;
			}
		}
		for(int n=1;n<=t;n++){
			int acmax=-1,penmin,maxteam=0;
			for(int i=1;i<=t;i++){
				if(acmax<ac[i]){
					maxteam=i;
					acmax=ac[i];
					penmin=pen[i];
				}
				else if(acmax==ac[i]&&pen[i]<penmin){
					maxteam=i;
					penmin=pen[i];
				}
			}
			cout<<maxteam<<" "<<ac[maxteam]<<" "<<pen[maxteam]<<endl;
			ac[maxteam]=-2;
		}
	}
    return 0;
}

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++;
    }
    ~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;
}