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 <bits/stdc++.h>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

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

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

struct team{
	int a,t,n;
	bool operator<(team &arg) const{
		if(a==arg.a&&t==arg.t) return n<arg.n;
		if(a==arg.a) return t<arg.t;
		return a>arg.a;
	}
};

team info[55];

int wrong[55][11];

int main(void){
	int t,p,r;
	while(cin >> t >> p >> r){
		if(t==0)
			break;
		rep(i,55)rep(j,11) wrong[i][j]=0;
		rep(i,55) info[i].a=info[i].t=0,info[i].n=i+1;
		rep(i,r){
			int tid,pid,times;
			cin >> tid >> pid >> times;
			string m;
			cin >> m;
			if(wrong[tid][pid]!=-1){
				if(m=="CORRECT"){
					info[tid-1].a++;
					info[tid-1].t+=(times+1200*wrong[tid][pid]);
					wrong[tid][pid]=-1;
				}else
					wrong[tid][pid]++;
			}
		}
		sort(info,info+t);
		rep(i,t) cout << info[i].n << " " << info[i].a << " " << info[i].t << endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
typedef tuple<int,int,int> Team;
int AC[50][10],WA[50][10];
int main() {
    int T,P,R;
    while(cin>>T>>P>>R,T) {
        memset(AC,0,sizeof(AC));
        memset(WA,0,sizeof(WA));
        for(int i=0;i<R;i++) {
            int tID,pID,time;
            string mes;
            cin>>tID>>pID>>time>>mes;
            tID--;pID--;
            if(mes=="CORRECT") {
                AC[tID][pID]=time;
            }else {
                WA[tID][pID]++;
            }
        }
        vector<Team> v;
        for(int i=0;i<T;i++) {
            int solved=0,penalty=0;
            for(int j=0;j<P;j++) {
                if(AC[i][j]) solved++,penalty+=AC[i][j]+WA[i][j]*1200;
            }
            v.push_back(make_tuple(-solved,penalty,i+1));
        }
        sort(v.begin(),v.end());
        for(int i=0;i<v.size();i++) {
            printf("%d %d %d\n",get<2>(v[i]),-get<0>(v[i]),get<1>(v[i]));
        }
    }
}

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

typedef struct {
    int tid;
    int pid;
    int time;
    string message;
} record;

typedef struct {
    int num;
    int solved;
    int penalty;
    int tmpPenalty;
} team;

int main(){
    team teams[51];
    record rec[501];
    int t, p, r;
    while (1){
	cin >> t >> p >> r;
	if (t == 0 && p == 0 && r == 0) break;

	for (int i = 0; i < r; i++){
	    cin >> rec[i].tid >> rec[i].pid >> rec[i].time >> rec[i].message;
	}
	
	for (int i = 0; i < t; i++){
	    teams[i].num = teams[i].tmpPenalty = teams[i].penalty = teams[i].solved = 0;
	}
	
	for (int i = 0; i < r; i++){
	    if(rec[i].message == "CORRECT") {
		teams[rec[i].tid].solved++;
		teams[rec[i].tid].penalty += (teams[rec[i].tid].tmpPenalty * 1200 + rec[i].time);
		teams[rec[i].tid].tmpPenalty = 0;
	    }
	    else if (rec[i].message == "WRONG") teams[rec[i].tid].tmpPenalty++;
	    teams[rec[i].tid].num = rec[i].tid;
	}

	// sort with solved
	team b;
	for (int j = 0; j < t*t*t; j++){
	    for (int i = 0; i < t-1; i++){
		if (teams[i].solved < teams[i+1].solved){
		    b = teams[i];
		    teams[i] = teams[i+1];
		    teams[i+1] = b;
		}
		if (teams[i].solved == teams[i+1].solved && teams[i].penalty > teams[i+1].penalty){
		    b = teams[i];
		    teams[i] = teams[i+1];
		    teams[i+1] = b;
		}
		if (teams[i].solved == teams[i+1].solved && teams[i].penalty > teams[i+1].penalty && teams[i].num > teams[i+1].num){
		    b = teams[i];
		    teams[i] = teams[i+1];
		    teams[i+1] = b;
		}
		
	    }
	}

	for (int i = 0; i < t; i++){
	    cout << teams[i].num << " " << teams[i].solved << " " << teams[i].penalty << endl;
	}
    }
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <map>
#include <set>
using namespace std;

#define rep(i,n) for(int i=0; i<n; i++)
#define FOR(i,s,n) for(int i=s; i<n; i++)
#define ALL(x) x.begin(), x.end()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;

struct Team {
	int id;
	int corr;
	ll pen;
};

bool operator<(const Team& lhs, const Team& rhs) {
	if( lhs.corr == rhs.corr ) {
		if( lhs.pen == rhs.pen ) {
			return lhs.id < rhs.id;
		}
		return lhs.pen < rhs.pen;
	}
	return lhs.corr > rhs.corr;
}

int main() {
	int T, P, R;
	while(cin >> T >> P >> R, T) {
		int wrong[51][11] = {};
		vector<Team> team(T);
		rep(i, T) {
			team[i].id = i+1;
		}
		rep(i, R) {
			int t, p, ti;
			string m;
			cin >> t >> p >> ti >> m;
			if( m == "CORRECT" ) {
				team[t-1].corr++;
				team[t-1].pen += 1200 * wrong[t][p] + ti;
			} else {
				wrong[t][p]++;
			}
		}
		sort( team.begin(), team.end() );
		rep(i, T) {
			cout << team[i].id << " " << team[i].corr << " " << team[i].pen << endl;
		}
	}
	return 0;
}