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<vector>
#include<algorithm>
using namespace std;
struct kk{
int id;
int ac;
int wa;
vector<int> p;//譬ク蝠城。後↓蟇セ縺吶ｋ繝壹リ繝ォ繝?ぅ
vector<bool>acs;
int psum;
};
//
kk ans[105];
int main(){
	int T,P,R;
	while(cin>>T>>P>>R&&(T+P+R)!=0){//T繝√?繝??P蝠?R蛟九?繝ュ繧ー
	for(int i=0;i<105;i++){
	ans[i].p.resize(180);
	ans[i].acs.resize(190);
	for(int j=0;j<103;j++)ans[i].p[j]=0,ans[i].acs[j]=0;
	ans[i].id=i;
	}

	for(int i=0;i<R;i++){
	int a,b,c;//id,蝠城。景d,邨碁℃譎る俣
	string d;//繝。繝?そ繝シ繧ク
	cin>>a>>b>>c>>d;
	if(d=="WRONG"){
	ans[a].p[b]++;
	}
	else if(d=="CORRECT"){
	ans[a].ac++;
	ans[a].acs[b]=true;
	ans[a].p[b]=ans[a].p[b]*1200+c;
	}
	}
	for(int i=1;i<=T;i++){
		int sum=0;
		for(int j=0;j<=P;j++)if(ans[i].acs[j])sum+=ans[i].p[j];
		ans[i].psum=sum;
	}

	//for(int i=1;i<=T;i++)cout<<ans[i].id<<" "<<ans[i].ac<<" "<<ans[i].psum<<endl;
	for(int i=1;i<=T;i++){
		for(int j=i+1;j<=T;j++){
			if(ans[i].ac<ans[j].ac)swap(ans[i],ans[j]);//蜿ウ縺ョ縺サ縺?′蠑キ縺代ｌ縺ーswap
			else if(ans[i].ac==ans[j].ac){

				if(ans[i].psum>ans[j].psum)swap(ans[i],ans[j]);
				if(ans[i].psum==ans[j].psum&&ans[i].id>ans[j].id)swap(ans[i],ans[j]);
			}
		}
	}
	for(int i=1;i<=T;i++){
	cout<<ans[i].id<<" "<<ans[i].ac<<" "<<ans[i].psum<<endl;
	}
		for(int i=0;i<=104;i++){ans[i].p.clear();ans[i].acs.clear();ans[i].psum=0;ans[i].ac=0;ans[i].wa=0;ans[i].id=0;}
	}
		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];
    team(){
        memset(wrong, 0, sizeof(wrong));
        id=now++;
    }
    vector <int> solved;
    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 argc, const char * argv[]) {
    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;
        }
    }
    
    return 0;
}

C++: #include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#define I (1<<21)
using namespace std;
int x[100], z[100], y[99][20], a, b, c, d, e, f, i, j, k; string S;
int main() {
	while (true) {
		memset(x, 0, sizeof(x));
		memset(y, 0, sizeof(y));
		cin >> a >> b >> c;
		if (a == 0) { break; }
		for (i = 0; i < c; i++) {
			cin >> d >> e >> f >> S;
			if (S[0] == 'W') {
				y[d][e] ++;
			}
			else {
				x[d] += I;
				x[d] += f + 1200 * y[d][e];
			}
		}
		for (i = 1; i <= a; i++) { z[i] = x[i]; }
		sort(x + 1, x + a + 1);
		for (i = a; i >= 1; i--) {
			for (j = 1; j <= a; j++) {
				if (z[j] == x[i]) {
					cout << j << ' ' << x[i] / I << ' ' << x[i] % I << endl;
				}
			}
		}
	}
}

C++: #include<bits/stdc++.h>
using namespace std;
#define I 900000
int x[99],z[99],y[99][20],h[99],a,b,c,d,e,f,i,j,k;string S;
int main(){
while(true){
for(i=0;i<99;i++){x[i]=I;}
memset(y,0,sizeof(y));
memset(h,0,sizeof(h));
cin>>a>>b>>c;
if(!a){break;}
for(i=0;i<c;i++){
cin>>d>>e>>f>>S;
if(S[0]=='W'){
y[d][e]++;
}
else{
x[d]+=I;
x[d]-=f+1200*y[d][e];
}
}
for(i=1;i<=a;i++){z[i]=x[i];}
sort(x+1,x+a+1);
for(i=a;i>=1;i--){
for(j=1;j<=a;j++){
if(z[j]==x[i]&&!h[j]){
printf("%d %d %d\n",j,(x[i]+I-1)/I-1,(99*I-x[i])%I);
h[j]=1;
}
}
}
}
}

C++: #include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long int ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back

vector<pii> score;
int pena[100][100];

void mysort(int ac[100]){
    for(int i=0;i<score.size()-1;i++){
        for(int j=i+1;j<score.size();j++){
//            if(score[i].first<score[j].first || ( score[i].first==score[j].first && score[i].second<score[j].second )){
            if(ac[score[i].second]<ac[score[j].second])swap(score[i],score[j]);
            else if(ac[score[i].second]==ac[score[j].second] && score[i].first>score[j].first)swap(score[i],score[j]);
            else if(ac[score[i].second]==ac[score[j].second] && score[i].first==score[j].first && score[i].second>score[j].second)swap(score[i],score[j]);
        }
    }
}


int main(){
    int t,p,r;
    while(cin>>t>>p>>r){
        int ac[100]={};
        if(t==0 && p==0 && r==0)break;
        score.clear();
        rep(i,t)score.pb(pii(0,i));
        rep(i,100)rep(j,100)pena[i][j]=0;
        
        
        rep(i,r){
            int team,prob,time;
            string mess;
            cin>>team>>prob>>time>>mess;
            team--;
            
            if(mess=="WRONG"){
                pena[team][prob]++;
            }else{
                score[team].first+=time+pena[team][prob]*1200;
                ac[team]++;
            }
        }
        
        mysort(ac);
        
        rep(i,score.size()){
            cout<<score[i].second+1<<" "<<ac[score[i].second]<<" "<<score[i].first<<endl;
        }
    }
    
    return 0;
}