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++: #define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define EPS 1e-10
using namespace std;
typedef long long llong;
class team {
public:
	int ac = 0, pe = 0, tid;
	vector<int>pid;

	bool operator <(team &other)const {
		if (this->ac == other.ac&&this->pe == other.pe)return this->tid < other.tid;
		else if (this->ac == other.ac)return this->pe < other.pe;
		else return this->ac > other.ac;
	}

};
int main() {
	int t, p, r;
	while (cin >> t >> p >> r,t||p||r) {
		vector<team>v(t);
		for (int i = 0; i < t; i++) {
			v[i].tid = i;
			v[i].pid = vector<int>(p, 0);
		}
		for (int i = 0; i < r; i++) {
			int tid, pid, time;
			string mes;
			cin >> tid >> pid >> time >> mes;
			tid--;
			pid--;
			if (mes == "WRONG") {
				v[tid].pid[pid]++;
			}
			else if (mes == "CORRECT") {
				v[tid].ac++;
				v[tid].pe += v[tid].pid[pid] * 1200 + time;
			}

		}
		sort(v.begin(), v.end());
		for (auto it = v.begin(); it != v.end(); it++) {
			cout << it->tid + 1 << " " << it->ac << " " << it->pe << endl;
		}
	}

	return 0;
}

C++: #define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to;
	ld cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
bool suf(ld a, ld b, ld c, ld d) {
	if (b <= c || d <= a) return 0;
	return 1;
}//[a,b),[c,d)
ll fact(ll x, ll k,ll p) {//最大値、個数
	ll sum = 1;
	for (int i = 0; i < k; i++) {
		sum *= (x--);
		sum %= p;
	}
	return sum;
}//階乗(正）
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res*x%p;
		x = x*x%p;
		n >>= 1;
	}
	return res;
}//x^n%p
#define int long long
const long long inf = 4523372036854775807;
const int iinf = 1500000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
int t, p, r;
int a[51];//スコアは？
int c[51];//問題の正解数
int w[51][51];//何回間違えたか
bool b[51][51];//問題を正解したか
struct A {
	int id, prob, pen;
};
bool operator<(A a, A b) {
	if (a.prob != b.prob) return a.prob < b.prob;
	if (a.pen != b.pen) return a.pen > b.pen;
	return a.id > b.id;
}
A d[51];
signed main() {
	while (cin >> t >> p >> r&&t + p + r > 0) {
		for (int i = 0; i < 51; i++) {
			for (int j = 0; j < 51; j++)
				w[i][j] = 0, b[i][j] = 0;
			a[i] = 0, c[i] = 0;
		}
		for (int i = 0; i < r; i++) {
			int tid, pid, time;
			string mes;
			cin >> tid >> pid >> time >> mes;
			if (!b[tid][pid]) {
				if (mes == "CORRECT") {
					a[tid] += w[tid][pid] * 1200 + time;
					c[tid]++;
					b[tid][pid] = 1;
				}
				else {
					w[tid][pid]++;
				}
			}
		}
		for (int i = 1; i <= t; i++) {
			d[i].id = i;
			d[i].pen = a[i];
			d[i].prob = c[i];
		}
		sort(d + 1, d + t + 1);
		reverse(d + 1, d + t + 1);
		for (int i = 1; i <= t; i++) {
			cout << d[i].id << " " << d[i].prob << " " << d[i].pen << endl;
		}
	}
	getchar(); getchar();
}

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

struct data{
    int n, solve, pena;
    int w[11] = {};

    void init(int i){
        n = i;
        solve = 0;
        pena = 0;
    }

    void submit(int p, int t, string judge){
        if(judge == "CORRECT"){
            solve++;
            pena += w[p]*1200+t;
        }else if(judge == "WRONG"){
            w[p]++;
        }
    }

    bool operator< (const data other) const{
        if(solve != other.solve)    return solve > other.solve;
        if(pena != other.pena)      return pena < other.pena;
        return n < other.n;
    }

    void print(){
        cout << n << " " << solve << " " << pena << endl;
    }
};

int main(){
    int t, p, r;
    while(cin >> t >> p >> r, t+p+r){
        vector<data> v(t);
        for(int i = 0; i < t; i++)  v[i].init(i+1);

        int a, b, c;
        string s;

        for(int i = 0; i < r; i++){
            cin >> a >> b >> c >> s;
            v[--a].submit(b, c, s);
        }

        sort(v.begin(), v.end());

        for(data d : v) d.print();
    }
    return 0;
}