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;

#define pb         push_back

const int INF = 1000000000;
const int MOD = 1000000007;

typedef struct _team{
	int tid;
	int solve;
	int wr[100] = {};
	int pen;
}Team;

bool CmpSolve(const Team& a, const Team& b){
	return (a.solve == b.solve) ? (a.pen == b.pen ? a.tid < b.tid : a.pen < b.pen) : a.solve > b.solve ;
}

int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);

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

		vector<Team> teams;

		for(int i=1; i<=t; i++){
			Team tmp;
			tmp.tid = i;
			tmp.solve = 0;
			tmp.pen = 0;
			teams.push_back(tmp);
		}

		for(int i=0; i<r; i++){
			int tid, pid, time;
			string mes;
			cin >> tid >> pid >> time >> mes;
			tid--;

			if(mes == "WRONG"){
				teams[tid].wr[pid]++;
			}else if(mes == "CORRECT"){
				teams[tid].solve++;
				teams[tid].pen += teams[tid].wr[pid]*1200 + time;
			}
		}

		sort(teams.begin(), teams.end(), CmpSolve);

		for(int i=0; i<t; i++){
			printf("%d %d %d\n", teams[i].tid, teams[i].solve, teams[i].pen);
		}

	}
	

	return 0;
}

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

// bad knowhow
#define REP(i,n) for(long long i=0;i<(long long)n;++i)


struct Score {
	Score() {}
	Score(int c, int p) : collects(c), penalty(p) {}
	bool operator<(const Score & other) const {
		if (collects == other.collects){
			if (penalty == other.penalty) return id < other.id;
			return penalty < other.penalty;
		}
		return collects > other.collects;
	}
	int collects;
	long long penalty;
	int id;
};

int wrong[50][10];
bool collect[50][10];
Score score[50];


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

		fill(score, score + 50, Score(0,0));
		fill(*collect, *collect + 500, false);
		fill(*wrong, *wrong + 500, 0);
		REP(i, t) score[i].id = i;

		REP(i, r) {
			int tid, pid, time;
			string message;
			cin >> tid >> pid >> time >> message;
			tid--; pid--;
			if (collect[tid][pid]) continue;
			if (message == "CORRECT") {
				score[tid].collects++;
				collect[tid][pid] = true;
				score[tid].penalty += wrong[tid][pid] * 1200 + time;
			} else {
				wrong[tid][pid]++;
			}
		}

		sort(score, score+t);
		REP(i, t) {
			cout << score[i].id + 1 << " " << score[i].collects << " " << score[i].penalty << endl;
		}
	}
}

C++: #include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

int main()
{
	typedef tuple<int, int, int> Data;

	cin.sync_with_stdio(false);
	int T, P, R;
	while (cin >> T >> P >> R, T)
	{
		vector<vi> wa(T, vi(P));
		vi ac(T), penalty(T);
		REP(i, R)
		{
			int tid, pid, time; string mes;
			cin >> tid >> pid >> time >> mes;
			tid--; pid--;
			if (mes == "CORRECT")
			{
				ac[tid]++;
				penalty[tid] += wa[tid][pid] * 1200 + time;
			}
			else
			{
				wa[tid][pid]++;
			}
		}
		vector<Data> v;
		REP(i, T) v.emplace_back(-ac[i], penalty[i], i + 1);
		sort(ALL(v));
		REP(i, T) cout << get<2>(v[i]) << " " << -get<0>(v[i]) << " " << get<1>(v[i]) << endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ALL(a) (a).begin(),(a).end()
#define pb(x) push_back(x)
#define ms(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(10) 
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef long long ll;
struct edge{ int from, to, cost; };

struct data{ int id, ac, pe; };
bool comp(const data& d1, const data& d2)
{
	if (d1.ac != d2.ac) return d1.ac > d2.ac;
	else if (d1.pe != d2.pe) return d1.pe < d2.pe;
	else return d1.id < d2.id;
}

int main()
{
	int t, p, r;
	while (cin >> t >> p >> r, t)
	{
		int wa[55][15];
		ms(wa, 0);
		data d[55];
		FOR(i, 1, t + 1) d[i] = data{ i, 0, 0 };
		REP(w, r)
		{
			int tid, pid, time;
			string mes;
			cin >> tid >> pid >> time >> mes;
			if (mes == "WRONG") wa[tid][pid] += 1200;
			else
			{
				d[tid].ac++;
				d[tid].pe += time + wa[tid][pid];
			}
		}
		sort(d + 1, d + t + 1, comp);
		FOR(i, 1, t + 1) cout << d[i].id << " " << d[i].ac << " " << d[i].pe << endl;
	}
	return 0;
}

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

#define rep(i,n) for(int i=0; i<n; i++)
typedef long long ll;

struct result {
	int pena, corr, tid;
	result(int t, int c, int p) {
		tid = t;
		corr = c;
		pena = p;
	}
};
bool operator<(const result& lhs, const result& rhs) {
	if( lhs.corr == rhs.corr ) {
		return lhs.pena < rhs.pena;
	}
	return lhs.corr > rhs.corr;
}

int main() {
	int t, p, r;
	while(cin >> t >> p >> r, t||p||r) {
		int pena[51] = {};
		int solved[51] = {};
		int wrong[51][11] = {};
		rep(i, r) {
			int tid, pid, time;
			string judge;
			cin >> tid >> pid >> time;
			cin >> judge;
			if(judge == "CORRECT") {
				solved[tid]++;
				pena[tid] += wrong[tid][pid] * 1200 + time;
			} else {
				wrong[tid][pid]++;
			}
		}
		vector<result> res;
		for(int id=1; id<=t; id++) {
			res.push_back(result(id, solved[id], pena[id]));
		}
		stable_sort( res.begin(), res.end() );
		rep(i, res.size()) {
			cout << res[i].tid << ' ' << res[i].corr << ' ' << res[i].pena << endl;
		}
	}
	return 0;
}