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<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include<algorithm>
#include<complex>
#include<cstdlib>
#include<cctype>

#define REP(i,n) for(int i = 0;i < (n);i++)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cout << v[i] << ' ';cout << endl << endl;}
#define SHOW2d(v,i,j) {for(int a = 0;a < i;a++){for(int b = 0;b < j;b++)cout << v[a][b] << ' ';cout << endl;}cout << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

struct score
{
	int team,pro,wrong[11];
	ll _time;
	
	score(int t){team = t;pro = _time = 0;REP(i,11)wrong[i] = 0;}
	
	bool operator<( const score& right ) const
	{
		return pro != right.pro ? pro > right.pro :
		_time != right._time ? _time < right._time : team < right.team;
	}
};

int main()
{
	int t,p,r;
	
	while(cin >> t >> p >> r,t|p|r)
	{
		vector<score> v;
		REP(i,t)
		{
			score tmp(i);
			v.PB(tmp);
		}
		
		REP(i,r)
		{
			int ttmp,ptmp,time;string str;
			cin >> ttmp >> ptmp >> time >> str;
			if(str == "CORRECT")
			{
				v[ttmp-1].pro++;
				v[ttmp-1]._time += time + v[ttmp-1].wrong[ptmp]*1200;
			}
			else
			{
				v[ttmp-1].wrong[ptmp]++;
			}
		}
		
		stable_sort(ALL(v));
		
		REP(i,t)
		{
			cout << v[i].team+1 << ' ' << v[i].pro << ' ' << v[i]._time << endl;
		}

	}		
		
		
			
	
	return 0;
}

C++: #include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-11;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
const int DX[8]={-1,0,1,0,-1,-1,1,1},DY[8]={0,-1,0,1,-1,1,-1,1};


int main(){
	while(1){
		int n,m,k;
		cin>>n>>m>>k;
		if(n==0) break;
		vip a(n);
		vvi b(n,vi(m));
		for(int i=0;i<n;i++) a[i].second=i+1;
		for(int i=0;i<k;i++){
			int x,y,z;
			string s;
			cin>>y>>z>>x>>s;
			y--;z--;
			if(s[0]=='W') b[y][z]++;
			else{
				a[y].first.first--;
				a[y].first.second+=b[y][z]*1200+x;
			}
		}
		sort(a.begin(),a.end());
		for(int i=0;i<n;i++){
			cout<<a[i].second<<' '<<-a[i].first.first<<' '<<a[i].first.second<<endl;
		}
	}
}

C++: #include<iostream>
#include<string>
using namespace std;
int x[100][2], y[99][20], a, b, c, d, e, f, i, j, k; string S;
int main() {
	while (true) {
		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][0]++;
				x[d][1] += f + 1200 * y[d][e];
			}
		}
		for (i = 10; i >= 0; i++) {
			for (j = 0; j < 99999; j++) {
				for (k = 1; k <= a; k++) {
					if (x[k][0] == i && x[k][1] == j) {
						cout << k << ' ' << i << ' ' << j << endl;
					}
				}
			}
		}
	}
}

C++: #include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define fi first
#define se second
#define pb push_back
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define REP(i,n) for(int i = 0;i < n; i++)
#define all(a) a.begin(),a.end()
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const long long MOD = 1000000007, INF = 1e18;

#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
 
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>vector<T>
make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}

int isPrime[111111];

signed main(){
	IOS();
	vector<int>ans;
	while(1){
		int T,P,R;
		cin>>T>>P>>R;
		if(!T&&!P&&!R)break;
		vector<int>t(T,0);
		int solved[T][P]={};
		int wa[T][P]={};
		rep(i,0,R){
			int teamID,problemID,time;
			string message;
			cin>>teamID>>problemID>>time>>message;
			teamID--;
			problemID--;
			if(solved[teamID][problemID]>0)continue;
			if(message=="CORRECT"){
				t[teamID]+=time;
				solved[teamID][problemID] = 1;
			}else{
				wa[teamID][problemID]++;
			}
		}
		vector<pair<pair<int,int>,int>>v(T);
		rep(i,0,T){
			int cnt = 0;
			int wrong = 0;
			rep(j,0,P)if(solved[i][j]){
				cnt++;
				wrong+=wa[i][j];
			}
			v[i].fi.fi=-cnt;
			v[i].fi.se=t[i]+wrong*1200;
			v[i].se=i;
		}
		sort(all(v));
		for(auto e:v){
			cout<<e.se+1<<" "<<-e.fi.fi<<" "<<e.fi.se<<endl;
		}
	}
	for(auto e:ans){
		cout<<e<<endl;
	}
}