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>
using namespace std;

struct P{
    int team;
    int ans;
    int sum;
    int pro[100];
    static bool point(const P& pleft,const P& pright){
        return pleft.sum < pright.sum;
    }
    static bool more(const P& mleft,const P& mright){
        return mleft.ans > mright.ans;
    }
};

int main(){
    int t,p,r,tid,pid,tim;
    string sta;
    while(cin >> t >> p >> r){
        if(t == 0 && r == 0 && p == 0) break;
        vector <P> data;
        P tmp;
        for(int i=0;i<t;i++){
            tmp.team = i+1;
            tmp.ans = 0;
            tmp.sum = 0;
            for(int j=0;j<=p;j++) tmp.pro[j] = 0;
            data.push_back(tmp);
        }
        while(r--){
            cin >> tid >> pid >> tim >> sta;
            if(sta == "CORRECT"){
                for(int i=0;i<t;i++){
                    if(data[i].team == tid){
                        data[i].sum += data[i].pro[pid]*1200+tim;
                        data[i].ans += 1;
                        data[i].pro[pid] = 0;
                        break;
                    }
                }
            }
            else if(sta == "WRONG"){
                for(int i=0;i<t;i++){
                    if(data[i].team == tid){
                        data[i].pro[pid] += 1;
                        break;
                    }
                }
            }
        }
        sort(data.begin(),data.end(),P::point);
        sort(data.begin(),data.end(),P::more);
        for(int i=0;i<t;i++) cout << data[i].team << " " << data[i].ans << " " << data[i].sum << endl;
    }
}

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

struct record {
	int id, correct, penalty;
	record(int i, int c = 0, int p = 0):id(i), correct(c), penalty(p){}

	bool operator>(const record& r) const {
		return correct > r.correct
			|| correct == r.correct && (penalty < r.penalty
										|| penalty == r.penalty && id < r.id);
	}

	void accept(int time) {
		++correct;
		penalty += time;
	}

	void print() {
		cout << id << " " << correct << " " << penalty << endl;
	}
};

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	for(int t, p, r; cin >> t >> p >> r, t;) {
		vector<vector<int> > wrong(t, vector<int>(p, 0));
		vector<record> records;
		records.reserve(t);
		for(int i = 1; i <= t; ++i)
			records.push_back(record(i));

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

			if(message[0] == 'C')
				records[tid].accept(time + wrong[tid][pid] * 1200);

			else
				++wrong[tid][pid];
		}

		sort(records.begin(), records.end(), greater<record>());
		for(int i = 0; i < (int)records.size(); ++i)
			records[i].print();
	}

	return EXIT_SUCCESS;
}

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

struct Team{
  int tid, cntWrong[11], penalty, AC;
  Team(int i){
    tid = i;
    for(int i = 1; i <= 10; i++) cntWrong[i] = 0;
    penalty = 0;
    AC = 0;
  }
};

vector<Team> teams;

void init(int T){
  for(int i = 1; i <= T; i++){
    teams.push_back(Team(i));
  }
}

bool compare(Team &t1, Team &t2){
  if(t1.AC != t2.AC) return t1.AC > t2.AC;
  else if(t1.penalty != t2.penalty) return t1.penalty < t2.penalty;
  else return t1.tid < t2.tid;
}

int main(void){
  int T, P, R;
  while(cin >> T >> P >> R && T != 0 && P != 0 && R != 0){
    int tid, pid, time;
    string message;
    teams.clear();
    init(T);
    for(int i = 0; i < R; i++){
      cin >> tid >> pid >> time >> message;
      if(message == "WRONG"){
        teams[tid-1].cntWrong[pid]++;
      }else if(message == "CORRECT"){
        teams[tid-1].penalty += teams[tid-1].cntWrong[pid] * 1200 + time;
        teams[tid-1].AC++;
      }
    }
    sort(teams.begin(), teams.end(), compare);
    for(int i = 0; i < T; i++){
      cout << teams[i].tid << " " << teams[i].AC << " " << teams[i].penalty << endl;
    }
  }
  return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define between(a,x,b) ((a)<=(x)&&(x)<=(b))
using namespace std;
typedef pair<int, pair<int, int> > tpair;

struct hoge{
  bool operator()(const tpair& a, const tpair& b){
    if(a.second.first != b.second.first) return a.second.first > b.second.first;
    else if(a.second.second != b.second.second) return a.second.second < b.second.second;
    else return a.first < b.first;
  }
};

int main(){
  int T, P, R;
  while(scanf("%d%d%d", &T, &P, &R) && (T||P||R)){
    //    vector<pair<int, pair<int, int> > > t(T); // team ac p
    vector<tpair> t(T);
    int fail[11][11] = {};
    int tid, pid, time;
    char message[16];
    rep(i, T) t[i].first = i+1;     
    rep(i, R){
      scanf("%d%d%d%s", &tid, &pid, &time, message); tid--; pid--;
      if(message[0] == 'C'){
	if(fail[tid][pid] != -1){
	  t[tid].second.first++;
	  t[tid].second.second += fail[tid][pid] * 1200 + time;
	  fail[tid][pid] = -1;
	}
      }else if(message[0] == 'W'){
	if(fail[tid][pid] != -1)
	  fail[tid][pid]++;
      }
    }
    sort(t.begin(), t.end(), hoge());
    rep(i, T) printf("%d %d %d\n", t[i].first, t[i].second.first, t[i].second.second);
  }
  return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
typedef pair<int,int> pii;
typedef pair<int,pii> pip;
#define rep(i,j) for(int i=0;i<(j);i++)
#define pb(i) push_back(i)
#define fs first
#define sc second
int state[50][10];

int main(){
	int T,P,R;
	while(cin>>T>>P>>R&&T){
		fill_n(state[0],500,0);
		vector<pip> v;
		rep(i,T)v.pb(pip(0,pii(0,1+i)));
		int t,p,ti;
		string s;
		rep(i,R){
			cin >>t>>p>>ti>>s;
			t--;
			p--;
			if(s[0]=='C'){
				v[t].fs--;
				v[t].sc.fs += state[t][p]*1200+ti;
			}else{
				state[t][p]++;
			}
		}
		sort(v.begin(),v.end());
		rep(i,T){
			cout << v[i].sc.sc << " " << -v[i].fs << " " << v[i].sc.fs << endl;
		}
	}
	return 0;
}