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 <vector>
#include <algorithm>

using namespace std;

#define RMAX 500
int tid[RMAX];
int pid[RMAX];
int time[RMAX];
int ok[RMAX];

#define TMAX 50
#define PMAX 10


int pen[TMAX][PMAX];
int pent[TMAX];
int cor[TMAX];


#define TEST 0

struct Dat{
	int team;
	int cor;
	int pent;
	Dat(int team,int cor,int pent):team(team),cor(cor),pent(pent){}
	bool operator<(const Dat& ano)const{
		if(cor!=ano.cor)return cor>ano.cor;
		if(pent!=ano.pent)return pent<ano.pent;
		return team<ano.team;
	}
};


int main(void){
	int t,p,r;
	while(scanf("%d%d%d",&t,&p,&r)==3&&(t||p||r)){
		for(int i=0;i<r;i++){
			scanf("%d%d%d",tid+i,pid+i,time+i);
			int ch;
			while((ch=getchar())<=' '){}
			ok[i]=ch=='C'?1:0;
			while(getchar()>' '){}
		}
		if(TEST){
			for(int i=0;i<r;i++){
				printf("%d\n",ok[i]);
			}
		}
		for(int i=0;i<t;i++){
			pent[i]=0;
			cor[i]=0;
			for(int j=0;j<p;j++){
				pen[i][j]=0;
			}
		}
		for(int i=0;i<r;i++){
			int team=tid[i]-1;
			int prob=pid[i]-1;
			if(ok[i]){
				cor[team]++;
				pent[team]+=pen[team][prob]+time[i];
			}else{
				pen[team][prob]+=1200;
			}
		}
		vector<Dat> vec;
		for(int i=0;i<t;i++){
			vec.push_back(Dat(i,cor[i],pent[i]));
		}
		sort(vec.begin(),vec.end());
		for(int i=0;i<vec.size();i++){
			printf("%d %d %d\n",vec[i].team+1,vec[i].cor,vec[i].pent);
		}
	}
	return 0;
}

C++: #define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>

using namespace std;

typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;

int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};

static const double EPS = 1e-8;

class Data{
public:
	int wrong[11];
	bool correct[11];
	int penalty;
	Data(){
		memset(wrong,0,sizeof(wrong));
		memset(correct,0,sizeof(correct));
		penalty = 0;
	}
};

class Team{
public:
	int solved;
	int penalty;
	int tid;
	Team (int _sol,int _pen,int _tid) : solved(_sol),penalty(_pen),tid(_tid) {}
	bool operator<(const Team& t){
		if(solved != t.solved){
			return solved > t.solved;
		}
		else if(solved == t.solved && penalty != t.penalty){
			return penalty < t.penalty;
		}
		else{
			return tid < t.tid;
		}
	}
};

int main(){
	int T,P,R;
	while(~scanf("%d %d %d",&T,&P,&R)){
		if(T==0 && P==0 && R==0) break;
		map<int,Data> status;
		for(int i=1;i<=T;i++){
			status[i];
		}
		for(int i=0;i<R;i++){
			int tID;
			int pID;
			int time;
			string str;
			cin >> tID >> pID >> time >> str;
			if(str == "CORRECT"){
				status[tID].correct[pID] = true;
				status[tID].penalty += status[tID].wrong[pID] * 1200 + time; 
			}
			else{
				if(!status[tID].correct[pID]) status[tID].wrong[pID]++;
			}
		}

		vector<Team> teams;

		for(map<int,Data>::iterator it = status.begin(); it != status.end(); it++){
			teams.push_back(Team(count(it->second.correct,it->second.correct + 11,true),it->second.penalty,it->first));
		}

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

		for(int i=0;i<teams.size();i++){
			printf("%d %d %d\n",teams[i].tid,teams[i].solved,teams[i].penalty);
		}
	}
}

C++: #include <iostream>
#define N 500
using namespace std;
struct info {
  int tid[N];
  int pid[N];
  int time[N];
  string message[N];
};
int main(){
  struct info data;
  int t,p,r,i,j,tcorrect[51][11],tp[51],twrong[51][11],tcsum[51],tnum[51];
  while(1){
    cin >> t >> p >> r;
    if(t==0&&p==0&&r==0) break;
    for(i=0;i<r;i++){
      cin >> data.tid[i] >> data.pid[i] >> data.time[i] >> data.message[i];
    }
    for(i=1;i<=t;i++){
      for(j=1;j<=p;j++){
    tcorrect[i][j]=twrong[i][j]=0;
      }
        tp[i]=0;
    }
    for(i=0;i<r;i++){
      if(data.message[i]=="CORRECT"){
    tcorrect[data.tid[i]][data.pid[i]]++;
    tp[data.tid[i]]=tp[data.tid[i]]+twrong[data.tid[i]][data.pid[i]]*1200+data.time[i];
      }
      else if(data.message[i]=="WRONG"){
    twrong[data.tid[i]][data.pid[i]]++;
      }
    }
    for(i=1;i<=t;i++){
      tcsum[i]=0;
      for(j=1;j<=p;j++){
    tcsum[i]+=tcorrect[i][j];
      }
      tnum[i]=i;
    }
    for(i=1;i<=t;i++){
      for(j=2;j<=t;j++){
    if(tnum[j]<tnum[j-1]){
      swap(tp[j],tp[j-1]);
      swap(tcsum[j],tcsum[j-1]);
      swap(tnum[j],tnum[j-1]);
    }
      }
    }
    for(i=1;i<=t;i++){
      for(j=2;j<=t;j++){
    if(tp[j]<tp[j-1]){
      swap(tp[j],tp[j-1]);
      swap(tcsum[j],tcsum[j-1]);
      swap(tnum[j],tnum[j-1]);
    }
      }
    }
    for(i=1;i<=t;i++){
      for(j=2;j<=t;j++){
    if(tcsum[j]>tcsum[j-1]){
      swap(tp[j],tp[j-1]);
      swap(tcsum[j],tcsum[j-1]);
      swap(tnum[j],tnum[j-1]);
    }
      }
    }
    for(i=1;i<=t;i++){
      cout << tnum[i] << ' ' << tcsum[i] << ' ' << tp[i] << endl;
    }
  }
  return 0;
}