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<cstdio>
#include<cstring>
#include<iostream>
using namespace std;

class team{
public:
	int ans[10][2];
	int id;
	int num;
	int total;
	void format(int id){
		memset(ans,0,sizeof(ans));
		this->id=id;
		total=0;
		num=0;
	}
	void set(int p,int time,int f){
		if(f!=0) ans[p][1]=time;
		else ans[p][0]++;
	}
	void set(){
		for(int i=0;i<10;i++){
			if(ans[i][1]>0){
				total+=(ans[i][0]*1200+ans[i][1]);
				num++;
			}
		}
	}
	bool operator<(team &obj){
		if(this->num<obj.num) return true;
		else if(this->num==obj.num){
			if(this->total<obj.total) return true;
			else if(this->total==obj.total){
				if(this->id<obj.id) return true;
			}
		}
		return false;
	}
	bool operator>(team &obj){
		if(this->num>obj.num) return true;
		else if(this->num==obj.num){
			if(this->total<obj.total) return true;
			else if(this->total==obj.total){
				if(this->id<obj.id) return true;
			}
		}
		return false;
	}
	team& operator=(team &obj){
		for(int i=0;i<10;i++){
			this->ans[i][0]=obj.ans[i][0];
			this->ans[i][1]=obj.ans[i][1];
		}
		this->id=obj.id;
		this->num=obj.num;
		this->total=obj.total;
		return *this;
	}
};

int c_cmp(const void *a,const void *b){
	return (*(team*)a>*(team*)b);
}

template<typename T> void qsort_s(int l,int r,T *data,int(*cmp)(const void*,const void*)){
	int i,j;
	T p;
	T buf;

	i=l;j=r;
	p=data[(l+r)/2];

	while(1) {
		while(cmp(&data[i],&p)) i++;
		while(cmp(&p,&data[j])) j--;
		if(i>=j) break;
		buf=data[i];
		data[i]=data[j];
		data[j]=buf;
		i++;
		j--;
	}

	if(l<i-1) qsort_s<T>(l,i-1,data,cmp);
	if(j+1<r) qsort_s<T>(j+1,r,data,cmp);
}

template<typename T> void qsort(T *data,int n,int(*cmp)(const void*,const void*)){
	qsort_s<T>(0,n-1,data,cmp);
}

team teams[50];

int main(){
	int t,r,p;
	int tid,pid,time;
	char message[10];
	while(cin>>t>>p>>r){
		if(t==0 && r==0 && p==0) break;
		for(int i=0;i<t;i++) teams[i].format(i);
		for(int i=0;i<r;i++){
			cin>>tid>>pid>>time>>message;
			teams[tid-1].set(pid-1,time,strcmp(message,"WRONG"));
		}
		for(int i=0;i<t;i++) teams[i].set();
		qsort<team>(teams,t,c_cmp);
		for(int i=0;i<t;i++) cout<<teams[i].id+1<<" "<<teams[i].num<<" "<<teams[i].total<<endl;
	}
	return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<math.h>
using namespace std;
#define mod (1000000000+7)
#define N (10007)
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P > T;

bool ac[52][12];
int wg[52][12];

bool cmp(const T &a,const T &b) {
    if(a.second.first != b.second.first) return a.second.first>b.second.first;
    else{
        if(a.second.second != b.second.second)return a.second.second < b.second.second;
        else return a.first < b.first;
    }
}


int main(void){
    int t,p,r;
    while(true){
        cin>>t>>p>>r;
        if(t==0 && p==0 && r==0)break;
        vector<T>ans(t);
        for(int i=0;i<t;i++)ans[i]=T(i+1,P(0,0));
        for(int i=0;i<52;i++){
            for(int j=0;j<12;j++){
                ac[i][j]=false;
                wg[i][j]=0;
            }
        }
        for(int i=0;i<r;i++){
            int x,y,time;
            string s;
            cin>>x>>y>>time>>s;
            int index =x-1;
            if(s == "WRONG"){
                if(!ac[x][y]){
                    wg[x][y]++;
                }
            }
            else{
                if(!ac[x][y]){
                    ans[index].second.first++;
                    ans[index].second.second += 1200*wg[x][y]+time;
                    ac[x][y]=true;
                }
            }
        }
        sort(ans.begin(),ans.end(),cmp);
        for(int i=0;i<t;i++){
            cout<<ans[i].first<<" "<<ans[i].second.first<<" "<<ans[i].second.second<<endl;
        }
    }
    return 0;
}

C++: #include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>

#define rep(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
using namespace std;

typedef struct{
	int wrong[11];
	int correct;
	int p_time;
	int num;
}Team;

int T, P, R;

bool judge(const Team rL, const Team rR){
	bool temp;
	if (temp = rL.correct > rR.correct)
		return(temp);
	else if (temp = rL.correct == rR.correct){
		if (temp = rL.p_time < rR.p_time)
			return(temp);
		else if (temp = (rL.p_time == rR.p_time&&rL.num < rR.num))
			return(temp);
	}
		return(temp);
}

void sswap(Team *a, Team *b){
	Team temp = *a;
	*a = *b;
	*b = temp;
}
void solve(Team team[]){
	rep(i, 0, T - 1)
	for (int j = T - 1; j > i; j--)
	{
		if (team[j].correct > team[j - 1].correct)
			sswap(team + j, team + j - 1);
		else if (team[j].correct == team[j - 1].correct){
			if (team[j].p_time < team[j - 1].p_time)
				sswap(team + j, team + j - 1);
			else if (team[j].p_time == team[j - 1].p_time&&team[j].num < team[j - 1].num)
				sswap(team + j, team + j - 1);
		}



	}
}

int main(){

	cin >> T >> P >> R;
	while (T != 0){
		Team team[51] = { { 0 }, 0, 0 };
		rep(i, 0, T)team[i].num = i + 1;
		rep(i, 0, R){
			int t, p, time;
			char str[20];
			cin >> t >> p >> time >> str;
			t--;
			if (strcmp(str, "WRONG")){
				team[t].correct++;
				team[t].p_time += time + team[t].wrong[p] * 1200;
			}
			else{
				team[t].wrong[p]++;
			}

		}
		//solve(team);
		sort(team, team + T, judge);
		rep(i, 0, T){
			cout << team[i].num << " " << team[i].correct << " " << team[i].p_time << endl;
		}
		cin >> T >> P >> R;
	}
	return(0);
}