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<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
#include<list>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {1, 1, 0, -1, -1, 0};
int dx[] = {1, 0, -1, -1, 0, 1};
#define ceil(a, b) a / b + !!(a % b)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)

bool comp(pair<pii, int> lhs, pair<pii, int> rhs) {
    if (lhs.first.first != rhs.first.first)
        return lhs.first.first > rhs.first.first;
    if (lhs.first.second != rhs.first.second)
        return lhs.first.second > rhs.first.second;
    return lhs.first.first > rhs.first.first;
}
int solve() {
    int n, p, r;
    cin >> n >> p >> r;
    if (n == 0 && p == 0 && r == 0) return -1;
    int co[n], wr[p][n], pen[p][n];
    rep(i, n) co[i] = 0;
    rep(i, p) rep(j, n) wr[i][j] = pen[i][j] = 0;
    rep(i, r) {
        int tid, pid, time; string mes;
        //problem id
        cin >> tid >> pid >> time >> mes;
        tid--; pid--;
        if (mes == "WRONG") {
            wr[pid][tid]++;
        } else {
            co[tid]++;
            pen[pid][tid] = wr[pid][tid] * 1200 + time;
        }
    }
    int tmp[n];
    rep(i, n) tmp[i] = 0;
    rep(i, n) rep(j, p) tmp[i] += pen[j][i];
    //rep(i, n) cout << co[i] << " "; cout << endl;
    /*
    rep(i, p) {
        rep(j, n) cout << pen[i][j] << " "; cout << endl;
    }
     */
    
    vector<pair<pii, int> > v(n);
    rep(i, n) {
        v[i].first.first = co[i];
        v[i].first.second = tmp[i];
        v[i].second = i;
        
    }
    sort(v.begin(), v.end(), comp);
    rep(i, n) {
        cout << v[i].second + 1 << " " << v[i].first.first << " " << v[i].first.second << endl;
    }
    return 0;
}
int main() {
    while (solve() == 0) {
        
    }
}

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--------------------*/
typedef tuple<int, int, int> Data;

int main()
{
	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 <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
# include <cstdlib>
# include <tuple>
# include <array>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2147483647;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr double HDINF = 50000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)      (x).begin(),(x).end()
# define UNIQUE(c)   sort(ALL((c)));(c).erase(unique(ALL((c))),(c).end())
# define LOWER(s)    transform(ALL((s)),(s).begin(),TL<char>)
# define UPPER(s)    transform(ALL((s)),(s).begin(),TU<char>)
# define FOR(i,a,b)  for(LL i=(a);i<(b);i++)
# define RFOR(i,a,b) for(LL i=(a);i>=(b);i--)
# define REP(i,n)    FOR(i,0,n)
# define INIT        std::ios::sync_with_stdio(false);std::cin.tie(0)

int t, p, r;
int points[100], pena[100], wacount[100][100];

int main() {
	while (cin >>t >> p >> r&&t&&p&&r) {
		REP(i, 100)points[i] = pena[i] = 0;
		REP(i, 100)REP(j, 100)wacount[i][j] = 0;
		REP(i, r) {
			int tid, pid, time;
			string mes;
			cin >> tid >> pid >> time >> mes;
			if (mes[0] == 'C') {
				points[tid]++;
				pena[tid] += wacount[tid][pid] * 1200 + time;
			}
			else {
				wacount[tid][pid]++;
			}
		}
		for (int q = 1; q <= t;q++) {
			int maxnum = -1, maxpos = -1, minpena = INF;
			for (int i = 1; i <= t;i++) {
				if (maxnum < points[i]) {
					maxnum = points[i];
					minpena = pena[i];
					maxpos = i;
				}
				else if (maxnum == points[i]) {
					if (minpena > pena[i]) {
						maxnum = points[i];
						minpena = pena[i];
						maxpos = i;
					}
				}
			}
			cout << maxpos << " " << points[maxpos] << " " << pena[maxpos] << endl;
			points[maxpos] = -INF;
			pena[maxpos] = INF;
		}
	}
}