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<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<stack>
#include<queue>
#include<sstream>
#include<string>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;


using namespace std;

struct Team{
  int t_num;
  int t_correct;
  int t_time;
  int t_wrong[11];
  Team(int n,int p){
    t_num=n;
    t_correct=0;
    t_time=0;
    rep(i,p) t_wrong[i]=0;
  }
};

//構造体ソート
class sort_type1{
  public:
    bool operator()(const Team& a,const Team& b){
      
      if(a.t_correct!=b.t_correct) return a.t_correct > b.t_correct;

      return a.t_time < b.t_time;
    }
};
class sort_type2{
  public:
    bool operator()(const Team& a,const Team& b){
      return a.t_time > b.t_time;
    }
};

int main(){
  
  while(1){
    int T,P,R;
    cin >> T >> P >> R;
    
    if(T==0&&P==0&&R==0) break;
    
    vector<Team> list;
    rep(i,T){
      Team tmp(i,P);
      list.push_back(tmp);
    }
    
    rep(i,R){
      int t,p,time;
      string str;
      cin >> t >> p >> time >> str;
      t--;p--;
      if(str=="WRONG"){
        list[t].t_wrong[p]++;
       // cout << "WRONG" << endl;
      }else if(str=="CORRECT"){
        
        list[t].t_time+=(1200*list[t].t_wrong[p]);
        list[t].t_time+=time;
        list[t].t_correct++;
      }
   }

    sort(list.begin(),list.end(),sort_type1());
    rep(i,list.size()){
      cout << list[i].t_num + 1 << " " << list[i].t_correct << " " <<list[i].t_time << endl;
    }
  }


}

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

// bad knowhow
#define REP(i,n) for(long long i=0;i<(long long)n;++i)

#include <set>

struct Score {
	Score() {}
	Score(int c, int p) : collects(c), penalty(p) {}
	bool operator<(const Score & other) {
		if (collects == other.collects){
			if (penalty == other.penalty) return id < other.id;
			return penalty < other.penalty;
		}
		return collects > other.collects;
	}
	int collects;
	long long penalty;
	int id;
};

int wrong[50][10];
bool collect[50][10];
Score score[50];


int main() {
	while (true) {
		fill(score, score + 50, Score(0,0));
		fill(*collect, *collect + 500, false);
		fill(*wrong, *wrong + 500, 0);

		int t, p, r;
		cin >> t >> p >> r;
		if (t == 0) break;

		REP(i, t) score[i].id = i;

		REP(i, r) {
			int tid, pid, time;
			string message;
			cin >> tid >> pid >> time >> message;
			tid--; pid--;
			if (collect[tid][pid]) continue;
			if (message == "CORRECT") {
				score[tid].collects++;
				collect[tid][pid] = true;
				score[tid].penalty += wrong[tid][pid] * 1200 + time;
			} else {
				wrong[tid][pid]++;
			}
		}

		sort(score, score+t);
		REP(i, t) {
			cout << score[i].id + 1 << " " << score[i].collects << " " << score[i].penalty << endl;
		}
	}
}

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

int main()
{
	int T, P, R;
	while (cin >> T >> P >> R && T != 0 && P != 0 && R != 0)
	{
		int accept[51][11] = {};
		int wrong[51][11] = {};
		int penalty[51] = {};
		int teamID[51] = {};
		for (int i = 1; i <= T; i++)
		{
			teamID[i] = i;
		}

		for (int i = 0; i < R; i++)
		{
			int tId,pId,time;
			cin >> tId >> pId >> time;
			char message[10];
			cin >> message;
			if (message[0] == 'C' && accept[tId][pId] == 0)
			{
				accept[tId][pId]++;
				penalty[tId] += (wrong[tId][pId] * 1200 + time);
			}
			else
			{
				wrong[tId][pId]++;
			}
		}
		int acceptSum[51];
		for (int i = 0; i < 51; i++)
		{
			acceptSum[i] = 99;
		}
		for (int i = 1; i <= T; i++)
		{
			int sum = 0;
			for (int j = 1; j <= P; j++)
			{
				sum += accept[i][j];
			}
			acceptSum[i] = sum;
		}
		for (int i = 1; i <= T - 1; i++)
		{
			for (int j = i + 1; j <= T; j++)
			{
				if (acceptSum[teamID[i]] < acceptSum[teamID[j]] ||
					(acceptSum[teamID[i]] == acceptSum[teamID[j]] && penalty[teamID[i]] > penalty[teamID[j]])|| 
					(acceptSum[teamID[i]] == acceptSum[teamID[j]] && penalty[teamID[i]] == penalty[teamID[j]] && teamID[i] > teamID[j]) )
				{
					int tmp = teamID[i];
					teamID[i] = teamID[j];
					teamID[j] = tmp;
				}
			}
		}
		
		for (int i = 1; i <= T; i++)
		{
			cout << teamID[i] << " " << acceptSum[teamID[i]] << " " << penalty[teamID[i]] << endl;
		}
	}
	return 0;
}