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++: /*
 * ICPCのジャッジプログラム
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2400
 */
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<climits>
#include<ctime>
#include<cstring>
#include<sstream>
#define REP(i,p,n) for(int i=p;i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep_split(tok,a_str,re) for(char *tok = strtok((char *)a_str.c_str(),re); tok != NULL; tok = strtok(NULL,re))
#define ALL(c) (c).begin(), (c).end()
#define dump(a) cerr << #a << "=" << (a) << endl
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> void chmin(T &t, T f) { if (t > f) t = f; } //t=min
template<class T> void chmax(T &t, T f) { if (t < f) t = f; } //t=max
using namespace std;


struct Team {
	int tID;
	int correct_cnt;
	int pena_time;
	bool operator<(const Team& right) const {
		if (correct_cnt == right.correct_cnt) {
			if (pena_time == right.pena_time) {
				return tID < right.tID; //小さい方が左側（順位が上）
			}
			else {
				return pena_time < right.pena_time; //少ない方が左側（順位が上）
			}
		}
		else {
			return correct_cnt > right.correct_cnt; //多い方が左側（順位が上）
		}
	}
};

int main() {
	int T,P,R;
	int tID,pID,time;
	string message;
	int wrong_cnt[51][11]; //T,P
	bool is_correct[51][11];

	while(cin >> T >> P >> R) {
		if (T==0&&P==0&&R==0) break;
		tID = pID = time = 0;
		message = "";
		Team teams[51];

		rep(i,51) {
			teams[i].tID = i;
			teams[i].correct_cnt= 0;
			teams[i].pena_time = 0;
		}
		fill_n((int *)wrong_cnt,sizeof(wrong_cnt)/sizeof(int),0);
		fill_n((int *)is_correct,sizeof(is_correct)/sizeof(int),0);

		rep(r,R) {
			cin >> tID >> pID >> time >> message;
			if (message == "CORRECT") {
				if (!is_correct[tID][pID]) {		
					teams[tID].correct_cnt++;
					teams[tID].pena_time+= wrong_cnt[tID][pID]*1200+time;
					is_correct[tID][pID] = true;
				}
			}
			else {
				wrong_cnt[tID][pID]++;
			}
		}
		sort(teams+1,teams+T+1);
		REP(i,1,T+1) {
			cout << teams[i].tID << " " << teams[i].correct_cnt << " " << teams[i].pena_time << endl;
		}

	}

	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;

struct team{
	int num;
	int ans;
	int time;
};

bool hikaku(const team &right,const team &left){
	return right.ans == left.ans ? right.time < left.time : right.ans > left.ans;
}

int main(){
	int t,p,r;
	int wrong[51][11];
	int res[51];
	int pe[51];
	vector<team> v;
	int tid,pid,time;
	string message;
	team te;
	while(1){
		cin >> t >> p >> r;
		if(t == 0)break;
		for(int i = 0;i <= t;i++){
			res[i] = 0;
			pe[i] = 0;
			for(int j = 0;j <= p;j++){
				wrong[i][j] = 0;	
			}
		}
		v.clear();
		for(int i = 0;i < r;i++){
			cin >> tid >> pid >> time >> message;
			if(message == "CORRECT"){
				res[tid]++;
				pe[tid] += wrong[tid][pid] * 1200 + time;
			}
			else if(message == "WRONG"){
				wrong[tid][pid]++;
			}
		}
		for(int i = 1;i <= t;i++){
			te.num = i;
			te.ans = res[i];
			te.time = pe[i];
			v.push_back(te);
		}
		sort(v.begin(),v.end(),hikaku);
		for(int i = 0;i < t;i++){
			cout << v[i].num << " " << v[i].ans << " " << v[i].time <<endl;
		}
	}
	return 0;
}

C++: #include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define EQ(a,b) (abs((a)-(b))<EPS)
int ac_num[51];
bool locked[51][11];
int wa_num[51][11];
ll penalty[51];
vi ans;
void correct(int tid,int pid,int time)
{
	if(locked[tid][pid])return;
	ac_num[tid]++;
	penalty[tid]+=wa_num[tid][pid]*1200+time;
	locked[tid][pid]=true;
	return ;
}
void wrong(int tid,int pid,int time)
{
	if(locked[tid][pid])return;
	wa_num[tid][pid]++;
	return ;
}
bool comp(int a,int b)
{
	if(ac_num[a]>ac_num[b])return true;
	else if(ac_num[a]<ac_num[b])return false;
	else
	{
		if(penalty[a]>penalty[b])return false;
		else if(penalty[a]<penalty[b])return true;
		else
		{
			if(a>b)return false;
			else return true;
		}
	}
}
int main()
{
	while(1)
	{
		ans.clear();
		memset(penalty,0,sizeof(penalty));
		memset(wa_num,0,sizeof(wa_num));
		memset(ac_num,0,sizeof(ac_num));
		memset(locked,0,sizeof(locked));
		int t,p,r;
		cin >> t >> p >> r;
		if(t==0&&p==0&&r==0)break;
		for(int i=0;i<r;i++)
		{
			int a,b,c;
			string s;
			cin >> a >> b >> c >> s;
			if(s[0]=='C')
			{
				correct(a,b,c);
			}
			else
			{
				wrong(a,b,c);
			}
		}
		for(int i=1;i<=t;i++)
		{
			ans.pb(i);
		}
		sort(ans.begin(),ans.end(),comp);
		for(int i=0;i<sz(ans);i++)
		{
			cout << ans[i] << ' ' << ac_num[ans[i]] << ' ' << penalty[ans[i]] << endl;
		}
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

typedef struct _st{
    int id;
    int ac;
    int pena;
} status;

bool cmp(status& a, status& b){
    if(a.ac != b.ac){
        return a.ac > b.ac;
    }else if(a.pena != b.pena){
        return a.pena < b.pena;
    }else{
        return a.id < b.id;
    }
}

int main(){
    while(1){
        int t,p,r;
        cin >> t >> p >> r;
        if(t==0) break;

        vector<status> st(t);
        for(int i=0; i<t; i++){
            st[i].id=i+1;
            st[i].ac=0;
            st[i].pena=0;
        }
        vector<vector<int> > wrong(t+1, vector<int>(p+1, 0));
        for(int i=0; i<r; i++){
            int tid,pid,time;
            string msg;
            cin >> tid >> pid >> time >> msg;
            if(msg[0] == 'W'){
                wrong[tid][pid]++;
            }else{
                st[tid-1].ac++;
                st[tid-1].pena += wrong[tid][pid]*1200 + time;
            }
        }

        sort(st.begin(), st.end(),cmp);
        for(int i=0; i<t; i++){
            cout << st[i].id << " " << st[i].ac << " " << st[i].pena << endl;
        }
    }
    return 0;
}