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 <algorithm>
#include <numeric>
#include <vector>
#include <cassert>
#include <string>
#include <memory.h>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <set>
#include <map>
#include <cctype>
#include <iomanip>
#include <sstream>
#include <cctype>
#include <fstream>
#include <cmath>
using namespace std;

#define REP2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define REP(i, n) REP2(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
#define ITER(c) __typeof((c).begin())
#define PB(e) push_back(e)
#define FOREACH(i, c) for(ITER(c) i = (c).begin(); i != (c).end(); ++i)
#define MP(a, b) make_pair(a, b)
#define PARITY(n) ((n) & 1)

typedef long long ll;
const int INF = 1000 * 1000 * 1000 + 7;
const double EPS = 1e-10;

int actime[60][20];
int nwrong[60][20];

int T, P, R;

bool accepted(int t, int p){
  return actime[t][p] > 0;
}

int acproblems(int t){
  int count = 0;
  for(int i = 0; i < 20; i++){
    if(actime[t][i] > 0) count++;
  }
  return count;
}
int totaltime(int t){
  int total = 0;
  for(int i = 0; i < 20; i++){
    if(actime[t][i] > 0){
      total += actime[t][i];
      total += nwrong[t][i] * 1200;
    }
  }
  return total;
}

int main(){
  int tID, pID, timei;

  string message;
  
  while(cin >> T >> P >> R && (T + P + R) > 0){
    memset(actime, 0, sizeof(actime));
    memset(nwrong, 0, sizeof(nwrong));

    while(R--){
      cin >> tID >> pID >> timei >> message;
      
      if(accepted(tID, pID)) continue;
      if(message == "CORRECT"){
        actime[tID][pID] = timei;
      }else{
        nwrong[tID][pID]++;
      }
    }
    
    vector<int> vi(T);
    
    REP(i, T) vi[i] = i + 1;
    for(int i = 0; i < T; i++){
      for(int j = 0; j < T - 1; j++){
        if(acproblems(vi[j]) < acproblems(vi[j+1]) ||
           (acproblems(vi[j]) ==acproblems(vi[j+1]) &&
            totaltime(vi[j]) > totaltime(vi[j+1])))
          swap(vi[j], vi[j+1]);
      }
    }
    
    for(int i = 0; i < T; i++){
      cout << vi[i] << " " << acproblems(vi[i]) << " " << totaltime(vi[i]) << endl;
    }
  }
  return 0;
}

C++: #include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
//#define int long long
#define INF 10000000
using namespace std;
int main(){
    int T,P,R;
    while(1){
        cin >> T >> P >> R;
        if(T == 0 && P == 0 && R == 0) break;
        int time_table[T][P] = {};
        int flag_table[T][P] = {};
        rep(i,R){
            int team,program,t;
            string flag;
            cin >> team >> program >> t >> flag;
            team--; program--;
            if(flag == "CORRECT"){
                time_table[team][program] = flag_table[team][program]*1200+t;
            }
            else if(flag == "WRONG"){
                flag_table[team][program]++;
            }
        }
        int top = -1;
        vector<pair<pair<int,int> , int> > ans(T);
        rep(i,T){
            int correct = 0;
            int fail = 0;
            rep(j,P){
                if(time_table[i][j] != 0) correct++;
                fail += time_table[i][j];
            }
            ans[i].first.first = -correct;
            ans[i].first.second = fail;
            ans[i].second = i+1;
        }
        sort(ans.begin(),ans.end());
        rep(i,ans.size()){
            cout << ans[i].second << " " << -ans[i].first.first << " " << ans[i].first.second << endl;
        }
    }
    return 0;
}

C++: #include <iostream>
#include <map>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

typedef struct TEAM{
	int tid;
	map<int,int> ptf;
	int score;
	int pena;

	bool operator < (const TEAM& oth)const{
		if(score==oth.score) {
			if(pena==oth.pena) return tid<oth.tid;
			return pena<oth.pena;
		}
		return score>oth.score;
	}

}TEAM_t;

int main(int argc, char const *argv[])
 {
 	int T,P,R;
 	int t,p,time_;
 	string s;

 	while(1){
 		cin>>T>>P>>R;
 		if(T+P+R==0) break;

 		vector<TEAM_t> team(T);

 		for(int i1=0;i1<T;i1++){
 			team[i1].tid=i1;
 			team[i1].score=0;
 			team[i1].pena=0;

 			for(int i2=0;i2<P;i2++){
				team[i1].ptf[i2]=0;
			}
 		}

 		for(int i1=0;i1<R;i1++){
 			cin>>t>>p>>time_>>s;
 			if(s=="CORRECT"){
 				team[t-1].score++;
 				team[t-1].pena+=time_+1200*team[t-1].ptf[p-1];
 			}
 			else {
 				team[t-1].ptf[p-1]++;
 			}
 		}

 		sort(team.begin(), team.end());

 		for(int i1=0;i1<T;i1++){
 			cout<<team[i1].tid+1<<" "<<team[i1].score<<" "<<team[i1].pena<<endl;
 		}
 		


 	}
 	return 0;
 }

C++: // You Are the Judge

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

struct DATA{
  int id,correct,penalty;
  vector<int>wrong;
  DATA(int i, int P){
    id=i;
    correct=penalty=0;
    wrong.resize(P);
    for(int i=0;i<P;i++)wrong[i]=0;
  }
};
bool operator<(DATA a, DATA b){
  return a.correct!=b.correct?a.correct>b.correct:(a.penalty!=b.penalty?a.penalty<b.penalty:a.id<b.id);
}

int main()
{
  int T,P,R;
  int t,p,time;
  string message;
  while(cin>>T>>P>>R,T|P|R){
    vector<DATA>team;
    for(int i=0;i<T;i++)team.push_back(DATA(i+1,P));
    for(int i=0;i<R;i++){
      cin>>t>>p>>time>>message;
      t--;
      p--;
      if(message=="WRONG"){
	team[t].wrong[p]++;
      }else{
	team[t].correct++;
	team[t].penalty+=team[t].wrong[p]*1200+time;
      }
    }
    sort(team.begin(),team.end());
    for(int i=0;i<T;i++){
      cout<<team[i].id<<" "<<team[i].correct<<" "<<team[i].penalty<<endl;
    }
  }
}