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 <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <ctime>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <numeric>
#include <cassert>
using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SS stringstream
#define DBG1(a) rep(_X,sz(a)){printf("%d ",a[_X]);}puts("");
#define DBG2(a) rep(_X,sz(a)){rep(_Y,sz(a[_X]))printf("%d ",a[_X][_Y]);puts("");}
#define bitcount(b) __builtin_popcount(b)
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)

#define delete(a,n) a.erase(remove(all(a),n),a.end())
template<typename T, typename S> vector<T>& operator<<(vector<T>& a, S b) { a.push_back(b); return a; }
template<typename T> void operator>>(vector<T>& a, int b) {while(b--)if(!a.empty())a.pop_back();}
bool isprime(int n){ if(n<2)return false;  for(int i=2;i*i<=n;i++)if(n%i==0)return false;  return true;} 
ll b_pow(ll x,ll n){return n ? b_pow(x*x,n/2)*(n%2?x:1) : 1ll;}
string itos(int n){stringstream ss;ss << n;return ss.str();}


vector< map<int,int> > wa,ac;
int T,P,R;
int main(){
	int n;
	while(cin >> T >> P >> R && T){
		wa.clear();
		wa.resize(T);
		ac.clear();
		ac.resize(T);
		
		for(int i = 0 ; i < R ; i++){
			int a,b,c;
			string d;
			cin >> a >> b >> c >> d;
			a--;
			if(ac[a].count(b)) continue;
			
			if( d == "CORRECT" ) ac[a][b] = c;
			else wa[a][b]++;
		}
		int id[50] = {};
		for(int i = 0 ; i < T ; i++) id[i] = i;
		for(int i = 0 ; i < T ; i++){
			for(int j = 0 ; j < T ; j++){
				if( ac[j-1].size() < ac[j].size() ){
					swap(ac[j-1],ac[j]);
					swap(wa[j-1],wa[j]);
					swap(id[j-1],id[j]);
				}else if(ac[j-1].size() == ac[j].size()){
					int penaltyA = 0 , penaltyB = 0;
					EACH(it,ac[j-1]) penaltyA += it->second + wa[j-1][it->first] * 1200;
					EACH(it,ac[j]) penaltyB += it->second + wa[j][it->first] * 1200;
					if( penaltyA != penaltyB ){
						if( penaltyA > penaltyB ){
							swap(ac[j-1],ac[j]);
							swap(wa[j-1],wa[j]);
							swap(id[j-1],id[j]);
						}
					}else{
						if( id[j-1] > id[j] ){
							swap(ac[j-1],ac[j]);
							swap(wa[j-1],wa[j]);
							swap(id[j-1],id[j]);
						}
					}
				}
			}
		}
		for(int i = 0 ; i < T ; i++){
			int p = 0;
			EACH(it,ac[i]) p += it->second + wa[i][it->first] * 1200;
			cout << id[i]+1 << " " << ac[i].size() << " " << p << endl;
		}
		
	}
}

C++: #include <bits/stdc++.h>
using namespace std;

typedef pair<int, int> P;

int main() {
	int t, p, r;
	while(cin >> t >> p >> r){
		int tid, pid, tm, rp[64][16] = {0};
		bool check[64][16] = {0};
		string message;
		vector<P> s;
		for(int i = 0; i < t; ++i){
			s.push_back(P(0, 0));
		}
		for(int i = 0; i < r; ++i){
			cin >> tid >> pid >> tm >> message;
			tid--;
			if(message == "CORRECT"){
				if(!check[tid][pid]){
					check[tid][pid] = true;
					s[tid].second += tm + rp[tid][pid] * 1200;
					s[tid].first--;
				}
			}
			else{
				rp[tid][pid]++;
			}
		}
		vector<P> rnk = s;
		stable_sort(s.begin(), s.end());
		bool is_out[64] = {0};
		for(int i = 0; i < t; ++i){
			for(int j = 0; j < t; ++j){
				if(rnk[j].first == s[i].first && rnk[j].second == s[i].second && !is_out[j]){
					is_out[j] = true;
					cout << j + 1 << " " << -s[i].first << " " << s[i].second << endl;
					break;
				}
			}
		}
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int inf = 1000000;
struct D{
	int tID;
	int p[10];	//the number of incorrect problems
	int c;		//the number of correct problems
	int x;		//penalty points
	/*D( int n ){
		tID = n;
		//p[10] = {{0}};
		c = 0;
		x = 0;
	}*/
};

bool rank( const D &a, const D &b ){
	return a.c == b.c ? (a.x == b.x ? a.tID < b.tID : a.x < b.x) : a.c > b.c;
}

int main(){
	int T, P, R;
	while( cin >> T >> P >> R && T ){
		vector< D > data(T);
		/*for( int i = 0; i < T; i++ ){
			data[i](i);
		}*/
		for( int i = 0; i < R; i++ ){
			int tID, pID, t;
			string m;
			cin >> tID >> pID >> t >> m;
			if( m == "CORRECT" ){
				if( data[tID-1].p[pID-1] != inf ){
					data[tID-1].c++;
					data[tID-1].x += t + data[tID-1].p[pID-1] * 1200;
					data[tID-1].p[pID-1] = inf;
				}
			}else{
				data[tID-1].p[pID-1]++;
			}
		}
		sort( data.begin(), data.end(), rank );
		for( int i = 0; i < T; i++ ){
			cout << data[i].tID << " " << data[i].c << " " << data[i].x << endl;
		}
	}
}

C++: #include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define between(a,x,b) ((a)<=(x)&&(x)<=(b))
using namespace std;
typedef pair<int, pair<int, int> > tpair;

struct hoge{
  bool operator()(const tpair& a, const tpair& b){
    if(a.second.first != b.second.first) return a.second.first > b.second.first;
    else if(a.second.second != b.second.second) return a.second.second < b.second.second;
    else return a.first < b.first;
  }
}; 

int main(){
  int T, P, R;
  while(scanf("%d%d%d", &T, &P, &R) && (T||P||R)){
    //    vector<pair<int, pair<int, int> > > t(T); // team ac p
    vector<tpair> t(T);
    int fail[11][11] = {};
    int tid, pid, time;
    char message[16];
    rep(i, T) t[i].first = i+1;     
    rep(i, R){
      scanf("%d%d%d%s", &tid, &pid, &time, message); tid--; pid--;
      if(message[0] == 'C'){
	if(fail[tid][pid] != -1){
	//  t[tid].second.first++;
	//  t[tid].second.second += fail[tid][pid] * 1200 + time;
	//  fail[tid][pid] = -1; 
	}
      }else if(message[0] == 'W'){
	if(fail[tid][pid] != -1)
	  fail[tid][pid]++;
      }
    } 
    sort(t.begin(), t.end(), hoge());
    rep(i, T) printf("%d %d %d\n", t[i].first, t[i].second.first, t[i].second.second);
  }
  return 0;
}