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 <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

class State
{
public:
	int No,ok,pena;
	State(int No = 0,int ok = 0, int pena = 0):
	No(No),ok(ok),pena(pena){}

	bool operator < (const State &ano) const{
		if(ok > ano.ok)return true;
		else if(ok == ano.ok && pena < ano.pena)return true;
		else if(ok == ano.ok && pena == ano.pena && No < ano.No)
			return true;
			return false;
	}
};

int main()
{
	int T,P,R;

	while(cin >> T >> P >> R, T){
		int **d = new int *[T];
		State *a = new State[T];
		for(int i = 0; i < T; i++){
			d[i] = new int [P];
			a[i].No = i+1,a[i].ok = 0,a[i].pena = 0;

			for(int j = 0; j < P; j++)
				d[i][j] = 0;
		}

		int team,prog,time;
		string str;
		while(R > 0){
			R--;
			cin >> team >> prog >> time >> str;

			if(str == "WRONG")
				d[team-1][prog-1]++;
			else {
				a[team-1].pena += d[team-1][prog-1]*1200+time;	//ペナルティ
				a[team-1].ok++;	//正解数
			}
		}

		sort(a,a+T);

		for(int i = 0; i < T; i++)
			printf("%d %d %d\n",a[i].No,a[i].ok a[i].pena);

			



	}

	return 0;
}

C++: #include<bits/stdc++.h>
typedef struct ICPC
{
  int team;
  int ac;
  int wa;
  int p[10];
}icpc;

#define AC "CORRECT"
#define WA "WRONG"
using namespace std;
int main()
{
  while(1)
    {
      icpc ic[100]={};
      int t,p,r;
      int i;
      int a,b,d;
      char c[100];
      
      for(i=0;i<100;i++)
	ic[i].team=i+1;
      
      cin>>t>>p>>r;
      if(t==0)break;
      
      for(i=0;i<r;i++)
	{
	  cin>>a>>b>>d;
	  scanf("%s",c);
	  if(!strcmp(c,AC))
	    ic[a-1].ac++,ic[a-1].wa+=1200*ic[a-1].p[b]+d;
	  else
	    ic[a-1].p[b]++;
	}
      int j;
      icpc temp;
      for(i=0;i<t-1;i++)
	for(j=i+1;j<t;j++)
	  {
	    if(ic[i].ac<ic[j].ac)
	      {
		temp=ic[i];
		ic[i]=ic[j];
		ic[j]=temp;
	      }
	    else if(ic[i].ac==ic[j].ac)
	      {
		if(ic[i].wa>ic[j].wa)
		  {
		    temp=ic[i];
		    ic[i]=ic[j];
		    ic[j]=temp;
		  }
		else if(ic[i].wa==ic[j].wa)
		  if(ic[i].team>ic[j].team)
		    {
		      temp=ic[i];
		      ic[i]=ic[j];
		      ic[j]=temp;
		    }
	      }
	  }

	       
      for(i=0;i<t;i++)
	cout<<ic[i].team<<" "<<ic[i].ac<<" "<<ic[i].wa<<endl;
    }
}

C++: #include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i = 0; i < n; ++i)
#define all(a) (a).begin(),(a).end()
#define fst first
#define snd second
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pii;
typedef pair<pii,ll> piii; // 正答数、時間、チーム

#define int ll
main(){
  int t,p,r;
  while(cin >> t >> p >> r,t){
    vector<vi> wanum(t,vi(p));
    vector<piii> result(t);
    rep(i,t) result[i].snd = i;
    int tid,pid,time;
    string m;
    rep(i,r){
      cin >> tid >> pid >> time >> m; tid--; pid--;
      if(m == "WRONG"){
	wanum[tid][pid]++;
      }else if(m == "CORRECT"){
	result[tid].fst.fst--;
	result[tid].fst.snd += wanum[tid][pid] * 1200 + time;
      }
    }
    sort(all(result));
rep(i,t) cout << result[i].snd+1 << " " << -result[i].fst.fst << " " << result[i].fst.snd << endl;
  }
}

C++: // AOJ 2400

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

#define score first.first
#define pena first.second
#define id second

int main(void)
{
	int t, p, r;
	while (cin >> t >> p >> r, r){
		int wrong[t][p];
		vector < pair < pair <int, int>, int> > team(t);
		for (int i = 0; i < t; i++){
			team[i].score = team[i].pena = 0;
			team[i].id = i + 1;
			fill (wrong[i], wrong[i] + p, 0);
		}
		int ti, pi, time;
		string mes;
		for (int i = 0; i < r; i++){
			cin >> ti >> pi >> time >> mes;
			ti--; pi--;
			if (mes == "WRONG"){
				wrong[ti][pi]++;
			}
			if (mes == "CORRECT"){
				team[ti].score++;
				team[ti].pena += (time + (1200 * wrong[ti][pi]));
			}
		}
		// cout << "check" << endl;
		
		int ret[t];
		for (int i = 0; i < team.size(); i++){
			int cnt = t-1;
			//　cout << "check" << endl;
			for (int j = 0; j < team.size(); j++){
				if (team[j].score < team[i].score) cnt--;
				if (team[j].score == team[i].score && team[i].pena < team[j].pena) cnt--;
				if (team[j].score == team[i].score && team[i].pena == team[j].pena && team[i].id < team[j].id) cnt--;
			}
			ret[cnt] = i;
		}
		for (int i = 0; i < t; i++){
			int rank = ret[i];
			cout << team[rank].id << " " << team[rank].score << " " << team[rank].pena << endl;
		}
	}
	
	return 0;
}

C++: #include <iostream>
#include <algorithm>

using namespace std;

#define T_MAX 64
#define P_MAX 16

class C_Team{
private :
	int id;
	int penalty;
	int correct;
	int wrong[P_MAX];
public :
	C_Team(){};
	C_Team(int tID);
	void Submit(int time, int pID, bool result);
	int GetCorrect() const { return correct; }
	int GetPenalty() const { return penalty; }
	int GetID() const { return id; }
};

// 判定基準
bool HighPoint(const C_Team& rteamLeft, const C_Team& rteamRight) {
	if(rteamLeft.GetCorrect() != rteamRight.GetCorrect()) return rteamLeft.GetCorrect() > rteamRight.GetCorrect();
	if(rteamLeft.GetPenalty() != rteamRight.GetPenalty()) return rteamLeft.GetPenalty() < rteamRight.GetPenalty();
	return rteamLeft.GetID() < rteamRight.GetID();
}

int main()
{
	while(1) {
		C_Team team[T_MAX];
		int t, p, r;
		cin >> t >> p >> r;
		if(!t && !p && !r) break;
		for(int i = 1; i <= t; i++) {
			team[i] = C_Team(i);
		}
		for(int i = 0; i < r; i++) {
			int tid, pid, time;
			string message;
			cin >> tid >> pid >> time >> message;
			team[tid].Submit(time, pid, message == "CORRECT");
		}
	
		sort(team+1, team+t+1, HighPoint);
		for(int i = 1; i <= t; i++) {
			cout << team[i].GetID() << " " << team[i].GetCorrect() << " " << team[i].GetPenalty() << endl;
		}
	}
	return 0;
}

C_Team::C_Team(int tID) {
	id = tID;
	correct = 0;
	penalty = 0;
	for(int i = 0; i < P_MAX; i++) {
		wrong[i] = 0;
	}
}

void C_Team::Submit(int time, int pID, bool result) {
	if(result) {
		correct++;
		penalty += wrong[pID] * 1200 + time;
	} else {
		wrong[pID]++;
	}
}