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<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


int main(){
  int t,p,r;
  int mp[50][13];
  //0 time 1=p problem p+1 solved p+2 num
  while(1){
    cin>>t>>p>>r;
    if(t==0 && p==0 && r==0) break;
    rep(i,t){
      rep(j,p+2){
	mp[i][j]=0;
      }
    }
    rep(i,t) mp[i][p+2]=i+1;
    int tid,pid,time;
    rep(k,r){
      cin>>tid>>pid>>time;
      string s;
      cin>>s;
      if(s=="WRONG"){
	mp[tid-1][pid]++;
      }
      else{
	mp[tid-1][0]+=time+mp[tid-1][pid]*1200;
	mp[tid-1][p+1]++;
      }
    }
    rep(i,t){
      repn(j,i){
	if(j==0) break;
	if(mp[j][p+1]>mp[j-1][p+1]) swap(mp[j],mp[j-1]);
	else if(mp[j][p+1]==mp[j-1][p+1]){
	  if(mp[j][0]<mp[j-1][0]) swap(mp[j],mp[j-1]);
	  else if(mp[j][0]==mp[j-1][0]){
	    if(mp[j][p+2]<mp[j-1][p+2]) swap(mp[j],mp[j-1]);
	    else break;
	  }
	  else break;
	}
	else break;
      }
    }
    
    rep(i,t){
      cout<<mp[i][p+2]<<" "<<mp[i][p+1]<<" "<<mp[i][0]<<endl;
    }
  }

  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
  while (1){
    int T, P, R;
    cin >> T >> P >> R;
    if (T == 0 && P == 0 && R == 0){
      break;
    }
    vector<vector<int>> s(T, vector<int>(P, 0));
    for (int i = 0; i < R; i++){
      int t, p, time;
      string message;
      cin >> t >> p >> time >> message;
      t--;
      p--;
      if (message == "CORRECT"){
        s[t][p] = time - s[t][p];
      }
      if (message == "WRONG"){
        s[t][p] -= 1200;
      }
    }
    vector<tuple<int, int, int>> ans(T);
    for (int i = 0; i < T; i++){
      int ac = 0;
      int time = 0;
      for (int j = 0; j < P; j++){
        if (s[i][j] > 0){
          ac++;
          time += s[i][j];
        }
      }
      ans[i] = make_tuple(ac, - time, - i);
    }
    sort(ans.rbegin(), ans.rend());
    for (int i = 0; i < T; i++){
      cout << - get<2>(ans[i]) + 1 << ' ' << get<0>(ans[i]) << ' ' << - get<1>(ans[i]) << endl;
    }
  }
}

C++: #include<iostream>
#include<cstdio>
#include<vector>
#include<cstring>
#include<cctype>
#include<algorithm>
#define rep(X,Y) for(int X=0;(X)<(Y);++X)
#define X first
#define Y second

using namespace std;

typedef pair<int,int> pii;
typedef pair<int,pii> piii;

int main(){
  int t,p,r;
  while(cin>>t>>p>>r,t){
    int sum[t][p];
    vector<piii> re(t);
    memset(sum,0,sizeof(sum));
    int a,b,c;
    string str;
    rep(i,r){
      cin>>a>>b>>c>>str;
      --a; --b;
      if(str[0]=='C'){
	++re[a].X;
	re[a].Y.X+=sum[a][b]+c;
      }else{
	sum[a][b]+=1200;
      }
    }
    rep(i,t){
      re[i].X*=-1;
      re[i].Y.Y=i;
    }
    sort(re.begin(),re.end());
    rep(i,t)
      cout<<re[i].Y.Y+1<<" "<<-re[i].X<<" "<<re[i].Y.X<<endl;
  }
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int ll;

int main(){
    int n,m,p;
    while(cin >> n >> m >> p,n&&m&&p){
        vector<vector<bool>> s(n,vector<bool>(m,false));
        vector<vector<int>> pe(n,vector<int>(m,0));
        vector<pair<pair<int,int>,int>> v;
        vector<int> num(n,0);
        vector<int> t(n,0);
        for(int i=0;i<p;i++){
            int a,b,c; string r; cin >> a >> b >> c >> r;
            a--; b--;
            if(s[a][b])continue;
            if(r[0]=='W'){
                pe[a][b]++;
            }
            else{
                num[a]++;
                t[a]+=c+pe[a][b]*1200;
            }
        }
        for(int i=0;i<n;i++){
            v.push_back(make_pair(make_pair(num[i],-t[i]),-(i+1)));
        }
        sort(v.rbegin(),v.rend());
        for(int i=0;i<n;i++){
            printf("%d %d %d\n",-v[i].second,v[i].first.first,-v[i].first.second );
        }
    }
}

C++: #include <bits/stdc++.h>
using namespace std;

struct Judge{
  int team, sum, score;
  int pena[100];
};

bool operator<(const Judge &a, const Judge &b){
  if(a.sum != b.sum) return a.sum > b.sum;
  else if(a.score != b.score) return a.score < b.score;
  else return a.team < b.team;
}

int main(){
  int t, p, r;
  while(cin >> t >> p >> r, t | p | r){
    Judge team[100];
    for(int i = 0; i < t; i++){
      team[i].team = i + 1;
      team[i].sum = 0;
      team[i].score = 0;
      for(int j = 0; j < 100; j++) team[i].pena[j] = 0;
    }
    for(int i = 0; i < r; i++){
      int id, pid, timer;
      string msg;
      cin >> id >> pid >> timer >> msg;
      if(msg == "WRONG"){
        for(int j = 0; j < t; j++){
          if(team[j].team == id) team[j].pena[pid]++;
        }
      }else if(msg == "CORRECT"){
        for(int j = 0; j < t; j++){
          if(team[j].team == id){
            team[j].score += timer + team[j].pena[pid] * 1200;
            team[j].sum++;
          }
        }
      }
    }
    sort(team, team+t);
    for(int i = 0; i < t; i++){
      cout << team[i].team << " " << team[i].sum << " " << team[i].score << endl;
    }
  }
  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;

typedef struct re{
  int AC;
  int WA[20];
  int pe;
  int tID;
  bool operator<(const re &right) const{
    return AC == right.AC ?(pe == right.pe ? tID > right.tID :pe > right.pe ) : AC < right.AC;
  }
  
}S;

int main(){
  int T ,P ,R ,tid, pid, time;
  string str = "CORRECT", temp;

  while(1){
    S a[100] = {};
    cin>>T>>P>>R;
    if(!T&&!P&&!R)break;
    for(int i = 0; i <= T; i++)a[i].tID = i;
    for(int i = 1; i <= R; i++){
      cin>>tid>>pid>>time>>temp;
      if(temp == str){
	a[tid].AC++;
	a[tid].pe += a[tid].WA[pid] * 1200 + time;
      } else{
	a[tid].WA[pid]++;
      }
    }
    sort(a+1, a+T+1);
    for(int i = T;i; i--){
      cout<<a[i].tID<<" "<<a[i].AC<<" "<<a[i].pe<<endl;
    }
  }
  
  return 0;
}