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 <vector>
#include <iostream>
#include <string>
#include <algorithm>
#include <tuple>
#define REP(i,n) for(int i=0;i<(n);i++)
#define P pair<int,int>
using namespace std;

int main(){
	int t,p,r;
	while(cin>>t>>p>>r,t){
		vector<tuple<int,int,int> > inf_team(t,tuple<int,int,int>(0,0,0));//problem,time,number
		REP(i,t)get<2>(inf_team[i]) = i;
		vector<vector<int> > penalty(t,vector<int>(p,0));
		REP(i,r){
			int t_id,p_id,time;
			string mes;
			cin >> t_id >> p_id >> time >> mes;
			t_id--;p_id--;
			if(mes=="WRONG"){
				penalty[t_id][p_id]++;
			}else{
				get<1>(inf_team[t_id]) += time + 1200*penalty[t_id][p_id];
				get<0>(inf_team[t_id])--;
			}
		}
		sort(inf_team.begin(),inf_team.end());
		REP(i,t){
			cout << get<2>(inf_team[i]) + 1 << " " << get<0>(inf_team[i]) * (-1) << " " << get<1>(inf_team[i]) << endl;
		}
	}
	return 0;
}

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

struct team {
	int seikai, ID, penarutii,gotou[10];
};
bool operator < (team a, team b) {
	if (a.seikai != b.seikai)return a.seikai > b.seikai;
	else if (a.penarutii!= b.penarutii)return a.penarutii< b.penarutii ;
	else return a.ID < b.ID;
}
int main() {
	int a, b, c;
	while (cin >> a >> b >> c, a || b || c) {
		team d[50]{};
		for (int k = 0; k < a; k++)d[k].ID = k;
		for (int e = 0; e < c; e++) {
			int f, g, h; string i;
			cin >> f >> g >> h >> i;
			if (i == "WRONG")d[f - 1].gotou[g-1]++;
			else {
				d[f - 1].seikai++;
				d[f - 1].penarutii += h + d[f - 1].gotou[g - 1] * 1200;
			}
		}
		sort(d, d + a);
		for (int i = 0; i < a; i++) {
			cout << d[i].ID + 1 << " " << d[i].seikai << " " << d[i].penarutii << endl;
		}
	}
}

C++: #include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
#define REP(i, b, e) for ( int i = b; i < (int)e; i++ )
#define rep(i, n) REP(i, 0, n)
static const int TMAX = 50;
static const int PMAX = 10;

class Team{
public:
  int nsolved, p;
  int T[PMAX];
  int TR[PMAX];
  int id;
  Team(){}
  Team(int id):id(id){
    rep(i, PMAX) T[i] = TR[i] = 0;
    nsolved = p = 0;
  }

  bool operator < ( const Team &t) const{
    if ( nsolved == t.nsolved ){
      if ( p == t.p ){
	return id < t.id;
      } else return p < t.p;
    } else return nsolved > t.nsolved;
  }
};
int T, P, R;

void simulate(){
  Team TM[TMAX];
  int tid, pid, tim;
  string mes;
  rep(i, T) TM[i] = Team(i+1);
  rep(i, R){
    cin >> tid >> pid >> tim >> mes;
    tid--; pid--;
    if ( mes == "CORRECT" ){
      if ( TM[tid].T[pid] == 0 ){
	TM[tid].T[pid] = tim; 
	TM[tid].p += tim + 1200*TM[tid].TR[pid];
	TM[tid].nsolved++;
      }
    } else {
      TM[tid].TR[pid]++;
    }
  }
  sort(TM, TM+T);
  rep(i, T){
    cout << TM[i].id << " " << TM[i].nsolved << " " << TM[i].p << endl;
  }

}

main(){
  while(1){
    cin >> T >> P >> R;
    if ( T == 0 ) break;
    simulate();
  }
}

C++: //ACCEPT????????????????????????Wrong Answer?????????????????£?????????????????????????????¨?????¨????????????
#include <iostream>
#include <string>
#include <tuple>
#include <algorithm>
using namespace std;

int T, P, R;
int team, prob, t; string mes;

bool isAccepted[50][10];
int acTimeSum[50];
int wrongCnt[50][10];

int main() {
	int i, j;
	
	while (cin >> T >> P >> R) {
		if (!T) break;
		for (i = 0; i < T; i++) {
			acTimeSum[i] = 0;
			for (j = 0; j < P; j++) {
				isAccepted[i][j] = false;
				wrongCnt[i][j] = 0;
			}
		}
		
		for (i = 0; i < R; i++) {
			cin >> team >> prob >> t >> mes;
			team--; prob--;
			if (mes == "CORRECT") {
				isAccepted[team][prob]++;
				acTimeSum[team] += t;
			}
			else {
				wrongCnt[team][prob]++;
			}
		}
		
		typedef tuple<int, int, int> Tuple;
		Tuple d[50];
		for (i = 0; i < T; i++) {
			int penalty = acTimeSum[i];
			int acCnt = 0;
			for (j = 0; j < P; j++) {
				if (isAccepted[i][j]) {
					acCnt++;
					penalty += 1200 * wrongCnt[i][j];
				}
			}
			d[i] = Tuple(-acCnt, penalty, i);
		}
		sort(d, d + T);
		
		for (i = 0; i < T; i++) {
			cout << get<2>(d[i]) + 1 << " " << -get<0>(d[i]) << " " << get<1>(d[i]) << endl;
		}
	}
	return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
#include<set>
using namespace std;


const long long int mod=1000000007;
const long long int INF=99999999999999999;


struct TEAM{
	long long int id,pena,ac;
};

bool cmp(TEAM x,TEAM y){
	if(x.ac!=y.ac){return x.ac>y.ac;}
	else if(x.pena!=y.pena){return x.pena<y.pena;}
	else{return x.id<y.id;}
}

long long int T,P,R;

int main() {
	
	cout << fixed << setprecision(18);
	cin>>T>>P>>R;
	while(T!=0){
		long long int tID[505],pID[505],tim[505],teampena[55][55]={};
		string str[505];
		TEAM team[55]={};
		
		for(int i=1;i<=T;i++){
			team[i].id=i;
		}
		for(int i=0;i<R;i++){
			cin>>tID[i]>>pID[i]>>tim[i]>>str[i];
			if(str[i]=="CORRECT"){team[tID[i]].ac++;team[tID[i]].pena+=teampena[tID[i]][pID[i]]+tim[i];}
			else{teampena[tID[i]][pID[i]]+=1200;}
		}

		sort(team+1,team+T+1,cmp);
		for(int i=1;i<=T;i++){
			cout<<team[i].id<<" "<<team[i].ac<<" "<<team[i].pena<<endl;
		}

		cin>>T>>P>>R;
	}
	
	
}