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 <string>
#include <algorithm>
#include <tuple>
#include <vector>
using namespace std;

int I, P, R;

int W[60][20]; // 不正解数
int C[60]; // 正解数
int T[60]; // 解答時間

int main() {
  while (scanf("%d%d%d", &I, &P, &R) != EOF && I) {
    fill(&W[0][0], &W[0][0]+60*20, 0);
    fill(C, C+60, 0);
    fill(T, T+60, 0);
    for (int i=0; i<R; i++) {
      int team, prob, time;
      string mes;
      cin >> team >> prob >> time >> mes;
      if (mes == "CORRECT") {
	C[team]++;
	T[team] += time + W[team][prob] * 1200;
      } else {
	W[team][prob]++;
      }
    }
    vector<tuple<int, int, int>> V;
    for (int i=1; i<=I; i++) {
      V.push_back(make_tuple(-1 * C[i], T[i], i));
    }
    sort(V.begin(), V.end());
    for (int i=0; i<I; i++) {
      cout << get<2>(V[i]) << " " << -1 * get<0>(V[i]) << " " << get<1>(V[i]) << endl;
    }
  }
}

C++: #include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<functional>
#include<stack>
#include <utility>

using namespace std;

int T[100000], P[10000], R[10000], tID[10000][500], pID[10000][500], time[10000][500], msg[10000][500], n = 0;

int main() {
	while (cin >> T[n] >> P[n] >> R[n]) {
		if (T[n] == 0)break;
		for (int j = 0; j < R[n]; j++) {
			string messege;
			cin >> tID[n][j] >> pID[n][j] >> time[n][j] >> messege;
			if (messege == "CORRECT")msg[n][j] = 1;
			else msg[n][j] = 0;
		}
		n++;
	}
	for (int i = 0; i < n; i++) {
		vector<pair<int, int>> AP, temp;
		AP.resize(T[i]);
		int WA[50][10]{ 0 };
		for (int j = 0; j < R[i]; j++) {
			if (msg[i][j] == 0) {
				WA[tID[i][j] - 1][pID[i][j] - 1]++;
			}
			else {
				AP[tID[i][j] - 1].first--;
				AP[tID[i][j] - 1].second += time[i][j] + WA[tID[i][j] - 1][pID[i][j] - 1] * 1200;
			}
		}
		temp = AP;
		sort(temp.begin(), temp.end());
		int j = 0, k = 0, memo[50]{0};
		while (j < T[i]) {
			if (memo[k] > 0) {
				k++;
				continue;
			}
			if (temp[j] == AP[k]) {
				cout << k + 1 << " " << -temp[j].first << " " << temp[j].second << endl;
				j++;
				memo[k]++;
				k = 0;
			}
			else k++;
		}
	}
	return 0;
}

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int T, P, R;
  while (cin >> T >> P >> R, T) {
    vector<int> ac(T), penalty(T);
    vector<vector<int>> wa(T, vector<int>(P));
    while (R--) {
      int i, j, t;
      string s;
      cin >> i >> j >> t >> s;
      --i, --j;
      if (s == "CORRECT") {
        ++ac[i];
        penalty[i] += wa[i][j] * 1200 + t;
      } else {
        ++wa[i][j];
      }
    }
    vector<int> idx(T);
    iota(begin(idx), end(idx), 0);
    stable_sort(begin(idx), end(idx), [&](int l, int r) {
      return ac[l] != ac[r] ? ac[l] > ac[r] : penalty[l] < penalty[r];
    });
    for (int i : idx) {
      cout << i + 1 << ' ' << ac[i] << ' ' << penalty[i] << '\n';
    }
  }
}

C++: #include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int t,p,r;

struct Team{
    int solved=0,penalty=0,teamid=0;
    Team(){}
    Team(int s,int p,int t) : solved(s),penalty(p),teamid(t){}

    bool operator < (const Team &te){
        if(solved != te.solved) return ( solved < te.solved );
        else if(penalty != te.penalty) return (penalty > te.penalty);
        else (teamid > te.teamid);
    }
};

void solve(){
    vector<int> tid(r),pid(r),ti(r);
    vector<string> message(r);
    rep(i,r) cin >> tid[i] >> pid[i] >> ti[i] >> message[i];
    rep(i,r) tid[i]--,pid[i]--;

    vector<vi> fa(t,vi(p,0));

    vector<Team> team(t);
    rep(i,t) team[i].teamid=i;
    rep(i,r){
        if(message[i]=="CORRECT"){
            team[tid[i]].solved++;
            team[tid[i]].penalty += ti[i] + 1200 * fa[tid[i]][pid[i]];
        }else{
            fa[tid[i]][pid[i]]++;
        }
    }
    sort(all(team));
    reverse(all(team));

    for(int i=0;i<t;i++){
        cout << team[i].teamid+1 << " " << team[i].solved << " " << team[i].penalty << endl;
    }
}

int main(){
    while(1){
        cin >> t >> p >> r;
        if(t==0 and p==0 and r==0) break;
        solve();
    }
}