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>

#define FOR(i, a, b) for(long long int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;



int main(void) {
	
	while (1) {
		int t, p, r;
		int tl, pl, time;
		int tmp1, tmp2;
		int pena[51][11] = {};
		int res[51] = {};
		int ans[51] = {};
		string message;

		cin >> t >> p >> r;
		if (t == 0) {
			break;
		}
		FOR(i, 1, r) {
			cin >> tl >> pl >> time >> message;
			if (message == "WRONG") {
				pena[tl][pl]++;
			}
			else {
				ans[tl]++;
				res[tl] += time + pena[tl][pl] * 1200;
			}
		}
		vector< pair<int, int> > dp(t);
		FOR(i, 1, t) {
			dp[i - 1].first = ans[i];
			dp[i - 1].second = i;
		}
		sort(dp.begin(), dp.end());
		RFOR(i, t-1, 1) {
			RFOR(u, i-1, 0) {
				if (dp[i].first == dp[u].first) {
					if (res[dp[i].second] > res[dp[u].second]) {
						tmp1 = dp[i].first;
						tmp2 = dp[i].second;
						dp[i].first = dp[u].first;
						dp[i].second = dp[u].second;
						dp[u].first = tmp1;
						dp[u].second = tmp2;
					}
					if (res[dp[i].second] == res[dp[u].second]) {
						tmp1 = dp[i].second;
						dp[i].second = dp[u].second;
						dp[u].second = tmp1;
					}
				}
			}
		}
		RFOR(i, t-1, 0) {
			cout << dp[i].second << " " << dp[i].first << " " << res[dp[i].second] << endl;
		}
	}
	
}

C++: #include<bits/stdc++.h>
using namespace std;
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
 
typedef long long ll;
typedef pair<int, int> ii;


struct NODE{
	int num;//team number
	vector<int> wrong;
	ll score;
	int solve;
	NODE(){}
	NODE(int num, int p):num(num), wrong(p, 0){score = 0; solve = 0;}
	
	bool operator<(const NODE r){
		if(solve != r.solve) return solve < r.solve;
		else if (score != r.score) return score > r.score;
		else return num > r.num;
	}
};

int main() {
	
	int t, p, r;
	while(cin >> t >> p >> r, t){
		vector<NODE> v(t);
		rep(i, t){
			v[i] = NODE(i, p);
		}
		
		rep(i, r){
			int tid, pid, time;
			string mes;
			cin >> tid >> pid >> time >> mes;
			tid--;
			pid--;
			if(mes == "CORRECT"){
				v[tid].score += (v[tid].wrong[pid] * 1200 + time);
				v[tid].solve++;
			}
			else{
				v[tid].wrong[pid]++;
			}
		}
		
		SORT(v);
		
		for(int i = t-1; i >=0; i--){
			cout << v[i].num+1 << " " << v[i].solve << " " << v[i].score << endl;
		}
	}
	
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
	int t,p,r;
	while(cin >> t >> p >> r,t){
		int tid,pid,time;
		string message;
		vector <pair <int,pair<int,int> >  >pen(t);
		for(int i=0;i<t;i++)
			pen[i].second.second=i+1;
		int wor[t][p];
		int done[t][p];
		for(int i=0;i<t;i++)
			for(int j=0;j<p;j++){
				wor[i][j]=0;
				done[i][j]=0;
			}
		for(int i=0;i<r;i++){
			cin >> tid >> pid >> time >> message;
			tid--; pid--;
			if(done[tid][pid]==1);
			else{
				if(message[0]=='W')
					wor[tid][pid]++;
				else{
					pen[tid].second.first+=wor[tid][pid]*1200+time;
					pen[tid].first++;
					done[tid][pid]=1;
				}
			}
		}
		sort(pen.begin(),pen.end());
		for(int i=0;i<t-1;i++){
			for(int j=0;j>i;j--){
				if(pen[i].first<pen[j].first){
					swap(pen[i].first,pen[j].first);
					swap(pen[i].second.first,pen[j].second.first);
					swap(pen[i].second.second,pen[j].second.second);
				}
			}
		}
		for(int i=0;i<t-1;i++){
			for(int j=t-1;j>i;j--){
				if(pen[i].second.first==pen[j].second.first&&pen[i].second.second>pen[j].second.second){
					swap(pen[i].first,pen[j].first);
					swap(pen[i].second.first,pen[j].second.first);
					swap(pen[i].second.second,pen[j].second.second);
				}
			}
		}
		for(int i=0;i<t;i++){
			cout << pen[i].second.second << " " << pen[i].first << " " << pen[i].second.first << endl;
		}
	}
}

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

using namespace std;

#define INF 999999999

struct team{
	int id, ac, pe;
	
	bool operator<(const team& a) const{
		if(ac != a.ac) return ac > a.ac;
		if(pe != a.pe) return pe < a.pe;
		if(id != a.id) return id < a.id;
	}
};

int main(){
	int i, j, t, p, r, tid, pid, time, wa[51][11];
	string ma;
	vector<team> set(51);
	while(1){
		cin >> t >> p >> r;
		if(!t) break;
		for(i=0;i<=t;i++){
			set[i].id = i;
			set[i].pe = 0;
			set[i].ac = 0;
			for(j=0;j<=p;j++) wa[i][j] = 0;
		}
		for(i=0;i<r;i++){
			cin >> tid >> pid >> time >> ma;
			if(ma == "WRONG") wa[tid][pid]++;
			else{
				set[tid].ac++;
				set[tid].pe += wa[tid][pid]*1200 + time;
			}
		}
		sort(set.begin()+1, set.begin()+t+1);
		for(i=1;i<=t;i++){
			cout << set[i].id << " " << set[i].ac << " " << set[i].pe << endl;
		}
	}
	return 0;
}

C++: #include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <set>
#include <map>
#include <cstring>
#include <cstdio>
#include <stack>
#define INF 1000000000
#define rep(i,n) for(int i =0;i<n;i++)
using namespace std;
typedef long long int ll;

int main(){
    for(;;){
        int t,p,r;
        cin >> t >> p >> r;
        if(!t and !p and !r) break;
        int g[t][p+3];
        memset(g, 0, sizeof(g));
        for (int i=0; i<r; i++) {
            int tid,pid,time;
            string message;
            cin >> tid >> pid >> time >> message;
            if (message=="CORRECT") {
                g[tid-1][p+1]++;
                g[tid-1][p+2]+=(time+g[tid-1][pid]*1200);
            }else{
                g[tid-1][pid]++;
            }
        }
        vector<pair<int, pair<int, int> > > h;
        for (int i=0; i<t; i++) {
            h.push_back({p-g[i][p+1],{g[i][p+2],i+1}});
        }
        sort(h.begin(), h.end());
        for (int i=0; i<h.size(); i++) {
            cout << h[i].second.second <<" "<<p-h[i].first<<" "<<h[i].second.first<<endl;
        }
    }
}