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 <cstring>
#include <map>
#include <algorithm>
#include <functional>
#define fi first
#define sec second
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> PP;

int t,p,r;
int team[50][10];
PP point[50];

int main(){
	int t, p, r;
	while(cin >> t >> p >> r,t||p||r){
		for(int i = 0; i < t; i++){
			for(int j = 0; j < p; j++) team[i][j] = 0;
			point[i].fi.fi = 0;
			point[i].fi.sec = 0;
			point[i].sec = -i-1;
		}
		for(int i = 0; i < r; i++){
			int tl, pl, ti;
			string m;
			cin >> tl >> pl >> ti >> m;
			tl--; pl--;
			if(team[tl][pl] < 0) continue;
			if(m[0] == 'W'){
				team[tl][pl]++;
			} else{
				point[tl].fi.fi++;
				point[tl].fi.sec -= 1200*team[tl][pl]+ti;
				team[tl][pl] = -1;
			}
		}
		sort(point,point+t,greater<PP>());
		for(int i = 0; i < t; i++){
			cout << point[i].sec*-1 << " " << point[i].fi.fi << " " << point[i].fi.sec*-1 << endl;
		}
	}
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;

struct teamscore{
  int t, c, p;
  int w[10];
};

bool comp(const teamscore &a, const teamscore &b)
{
  if(a.c != b.c)
    return a.c > b.c;
  else if(a.p != b.p)
    return a.p < b.p;
  else
    return a.t < b.t;
}

int main()
{
  while(1){
    int T, P, R;
    cin >> T >> P >> R;
    if(T == 0 && P == 0 && R == 0) break;
    vector<teamscore> v(T);
    REP(i,T){
      v[i].t = i+1;
      v[i].c = v[i].p = 0;
      REP(j,10)
        v[i].w[j] = 0;
    }
    REP(i,R){
      int team, p, time;
      string m;
      cin >> team >> p >> time >> m;
      if(m == "WRONG"){
        v[team-1].w[p-1]++;
      }else{
        v[team-1].p += v[team-1].w[p-1]*1200 + time;
        v[team-1].c++;
      }
    } 
    sort(v.begin(), v.end(), comp);
    REP(i,T)
      cout << v[i].t << " " << v[i].c << " " << v[i].p << endl;
  }
}

C++: #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <cstring>
#include <cctype>
#include <sstream>
#include <set>
#include <map>
#include <queue>
#include <complex>
using namespace std;
#define REP(i,n) for(int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for(int i = a; i < (int)b; i++)
const int INF = 1<<28;

bool com(const pair<int, pair<int, int> >& left, const pair<int, pair<int, int> >& right) {
	if(left.second.first == right.second.first) {
		if(left.second.second == right.second.first)
			return left.first < right.first;
		else
			return left.second.second < right.second.second;
	}
	else
		return left.second.first > right.second.first;
}

int main() {
	int T, P, R;
	while(cin >> T >> P >> R, T|P|R) {
		vector< pair<int, pair<int, int> > > vp;
		multiset<int> w;
		REP(i, T)
			vp.push_back(make_pair(i+1, make_pair(0, 0)));
		REP(j, R) {
			int tid, pid, time;
			string message;
			cin >> tid >> pid >> time >> message;
			if(message == "CORRECT") {
					vp[tid-1].second.first++;
					vp[tid-1].second.second += w.count(tid * 100 + pid) * 1200 + time;
			}
			else if(message == "WRONG")
				w.insert(tid * 100 + pid);
		}
		sort(vp.begin(), vp.end(), com);
		REP(i, vp.size())
			cout << vp[i].first << ' ' << vp[i].second.first << ' ' << vp[i].second.second << endl; 
	}
	return 0;
}

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

class team{
	private:
		int teamID, penalty, accept;
		vector<int> wrong;
	public:
		team(int ID, int numpro):teamID(ID), penalty(0),accept(0), wrong(numpro, 0){}
		void correct(int pID, int time){
			accept++;	
			penalty+=1200*wrong[pID]+time;
		}
		void notCorrect(int pID){
			wrong[pID]++;
		}
		void print()const {
			cout << teamID << " " << accept << " " << penalty << endl;
		}
		bool operator<(const team & t)const{
			if(accept != t.accept) return accept < t.accept;
			if(penalty != t.penalty) return penalty > t.penalty;
			return teamID > t.teamID;
		}
};
int main(){
	int T,P,R;
	while((cin>>T>>P>>R)&&T!=0){
		vector<team> teams;
		for(int i=1;i<=T;i++){
			teams.push_back(team(i,P));
		}
		for(int i=1;i<=R;i++){
			int tid, pid, time;
			string message;
			cin>>tid>>pid>>time>>message;
			tid--;
			pid--;
			if(message == "CORRECT"){
				teams[tid].correct(pid,time);
			}
			else{
				teams[tid].notCorrect(pid);
			}
		}
		sort(teams.rbegin(), teams.rend());
		for(const team& t : teams) {
			t.print();
		}
	}
}

C++: #include<iostream>
#include<string>
#include<queue>
#include<algorithm>
using namespace std;
int main(){
  int t,p,r,a,b,c;
  string d;
  while(cin>>t>>p>>r,t){
    int th[55][2]={},w[55][11]={};
    for(int i=0;i<r;i++){
      cin>>a>>b>>c>>d;
      if(d=="WRONG")w[a][b]++;
      else{
	th[a][0]++;
	th[a][1]+=w[a][b]*1200+c;
      }
    }
    priority_queue<pair<int,pair<int,int> > > ans;
    for(int i=1;i<=t;i++){
      ans.push(make_pair(th[i][0],make_pair(-th[i][1],-i)));
    }
    while(!ans.empty()){
      cout<<-1*ans.top().second.second<<" "<<ans.top().first<<" "<<-1*ans.top().second.first<<endl;
      ans.pop();
    }
  }
  return 0;
}