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 <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 10e9+9
#define EPS 1e-10
#define MAX_N 100100
#define MAX_M 100100

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int t, p, r;
int tid, pid, TIME;
string m;
P team[100];//????´???°???tid;first:correct,second:penalty
int inco[100][100];
vector< P > vp;
bool used[100];

bool flag(P p1, P p2){
	if (p1.first == p2.first)return p1.second < p2.second;
	return p1.first > p2.first;
}

int main(){
	while (cin >> t >> p >> r&&t + p + r){
		vp.clear();
		fill(used, used + 100,0);
		REP(i, 100)team[i] = P(0, 0);
		REP(i, 100)REP(j, 100)inco[i][j] = 0;
		REP(i, r){
			cin >> tid >> pid >> TIME >> m;
			if (m == "CORRECT"){
				team[tid].first++;
				team[tid].second += inco[tid][pid] * 1200 + TIME;
			}
			else{
				inco[tid][pid]++;
			}
		}
		FOR(i, 1, t + 1){
			vp.push_back(team[i]);
		}
		sort(ALL(vp), flag);
		REP(i, vp.size()){
			FOR(j, 1, t + 1){
				if (vp[i] == team[j] && !used[j]){
					cout << j << " " << vp[i].first
						<< " " << vp[i].second << endl;
					used[j] = 1;
				}
			}
		}
	}
}

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

int t, p, r, tID, pID, times;
int point[100], wrong[100][100], penalty[100], ans[100];
string message;

bool AC_comp(const int &a, const int &b){
    if(point[a] == point[b])
	return penalty[a] < penalty[b];
    return point[a] > point[b];
}

int main(){
    while(true){
	cin >> t >> p >> r;
	if(t == 0 && p == 0 && r == 0)return 0;
	memset(point, 0, sizeof(point));
	memset(penalty, 0, sizeof(penalty));
	memset(wrong, 0, sizeof(wrong));
	for(int i = 0;i < r;i++){
	    cin >> tID >> pID >> times >> message;
	    if(message == "CORRECT"){
		point[tID]++;
		penalty[tID] += times + wrong[tID][pID] * 1200;
	    }
	    else{
		wrong[tID][pID]++;
	    }
	}
	for(int i = 0;i < t;i++){
	    ans[i] = i + 1;
	}
	sort(ans, ans + t, AC_comp);
	for(int i = 0;i < t;i++){
	    int team = ans[i];
	    cout << team << ' ' << point[team] << ' ' << penalty[team] << endl;
	}
    }
}

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

int wa[51][11];

struct Team {
    int ac, wa, id;
};
bool operator<(const Team &t, const Team &s) {
    return (t.ac != s.ac) ? t.ac > s.ac
              : ((t.wa != s.wa) ? t.wa < s.wa
                 : t.id > s.id);
}

int main() {
    int T, P, R;
    while(cin>>T>>P>>R, T|P|R) {
        memset(wa, 0, sizeof(wa));
        vector<Team> team(T, (Team){0,0,0});
        for (int i=0; i<T; ++i) team[i].id = i+1;
        int t, p, tt;
        string m;
        for (int i=0; i<R; ++i) {
            cin>>t>>p>>tt>>m; t--, p--;
            if (m == "CORRECT") {
                team[t].ac++;
                team[t].wa += 1200 * wa[t][p] + tt;
            } else wa[t][p]++;
        }
        sort(team.begin(), team.end());
        for (int i=0; i<T; ++i)
            cout<<team[i].id<<" "<<team[i].ac<<" "<<team[i].wa<<endl;
    }
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
	int t,q,n;
	while(cin>>t>>q>>n,t){
		pair<int,pair<int,int> >a[50];
		for(int i=0;i<50;i++)a[i].second.second=i+1;
		while(n--){
			int a1,a2,a3;
			string s;
			cin>>a1>>a2>>a3>>s;
			if(s[0]=='W'){
				a[a1-1].second.first+=1200;
			}
			else{
				a[a1-1].first++;
				a[a1-1].second.first+=a3;
			}
		}
		sort(a,a+t);
		for(int i=t-1;i>=0;i--){
			cout<<a[i].second.second<<' ';
			cout<<a[i].first<<' ';
			cout<<a[i].second.first<<endl;
		}
	}
}

C++: #include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
struct team{
  int point,penalty,wrong[11],id;
  bool operator<(const team& a)  const{
    return point == a.point ? (penalty == a.penalty ? id < a.id : penalty < a.penalty) : point > a.point; 
  }
};
int main(){
  int t,p,r,i,j,k,b,o,tid,pid,time;
  string str;
  cin >> t >> p >> r;
  while(t!=0||p!=0||r!=0){
    vector <team> teams;
    for(i=1;i<=t;i++){
      team t;
      t.id=i;
      t.point=0;
      for(j=0;j<11;j++)
      t.wrong[j]=0;
      t.penalty=0;
      teams.push_back(t);
    }
    for(i=0;i<r;i++){
      cin >> tid >> pid >> time >> str;
      if(str[0]=='C'){
	teams[tid-1].point++;
	teams[tid-1].penalty+=teams[tid-1].wrong[pid]*1200+time;
      }else{
	teams[tid-1].wrong[pid]++;
      }
    }
    sort(teams.begin(),teams.end());
    for(i=0;i<t;i++){
      cout << teams[i].id << " " << teams[i].point << " " << teams[i].penalty << endl;
    }
    cin >> t >> p >> r;
  }
  return 0;
}

C++: #include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
typedef pair<int,int> p;
typedef pair<int,p> P;//first>正答数 second.first>ペナルティ second.second>チーム番号

int main()
{
	int t,p,r;
	while(cin>>t>>p>>r,t)
	{
		P res[t];
		int wa[t][11];
		for(int i=0;i<t;i++)
		{
			res[i].first=0;res[i].second.first=0;res[i].second.second=i+1;
		}
		memset(wa,0,sizeof(wa));
		for(int i=0;i<r;i++)
		{
			int tid,pid,tim;
			string mes;
			cin>>tid>>pid>>tim>>mes;
			if(mes=="WRONG")
			{
				wa[tid-1][pid]++;
			}
			else
			{
				res[tid-1].first--;
				res[tid-1].second.first+=wa[tid-1][pid]*1200+tim;
			}
		}

		sort(res,res+t);

		for(int i=0;i<t;i++)
		{
			cout<<res[i].second.second<<" "<<res[i].first*-1<<" "<<res[i].second.first<<endl;
		}
	}
	return 0;
}