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 <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define between(a,x,b) ((a)<=(x)&&(x)<=(b))
using namespace std;
typedef pair<int, pair<int, int> > tpair;


bool cmp(const tpair &a, const tpair &b){
  if(a.second.first != b.second.first) return a.second.first > b.second.first;
  else if(a.second.second != b.second.second) return a.second.second < b.second.second;
  else return a.first < b.first;
}


int main(){
  int T, P, R;
  while(scanf("%d%d%d", &T, &P, &R) && (T||P||R)){
    //    vector<pair<int, pair<int, int> > > t(T); // team ac p
    vector<tpair> t(T+1);
    int fail[11][11] = {};
    int tid, pid, time;
    char message[64];
    rep(i, T+1) t[i] = make_pair(i, make_pair(0, 0));
    rep(i, R){
      scanf("%d%d%d", &tid, &pid, &time);

      scanf("%s", message);
      if(message[0] == 'C'){
//	  t[tid].second.first += 1;
//	  t[tid].second.second += fail[tid][pid] * 1200 + time;
	  fail[tid][pid] = -1;
      }else  fail[tid][pid]++;
    }
    sort(t.begin(), t.end(), cmp);
    rep(i, T+1) if(t[i].first) printf("%d %d %d\n", t[i].first, t[i].second.first, t[i].second.second);
  }
  return 0;
}

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

using namespace std;

struct team{
    int num;
    int ac;
    int pen;

    bool operator<(const team &arg) const{
        if(ac != arg.ac){
            return ac > arg.ac;
        }else if(pen != arg.pen){
            return pen < arg.pen;
        }else{
            return num < arg.num;
        }
    }

    team(int _n, int _ac, int _pen):num(_n),ac(_ac),pen(_pen){}

};

int main(){
    int t,p,r;

    while(cin >> t >> p >> r){
        if((t|p|r) == 0) break;
        vector<team> teams;
        int wa_cnt[t+1][p+1];
        bool aced[t+1][p+1];
        int tid,pid,time;
        string mes;

        memset(wa_cnt, 0, sizeof(wa_cnt));
        memset(aced, 0, sizeof(aced));


        for(int i=0;i<t;i++){
            teams.push_back(team(i+1,0,0));
        }

        for(int i=0;i<r;i++){
            cin >> tid >> pid >> time >> mes;
            if(aced[tid][pid]) continue;

            if(mes == "CORRECT"){
                teams[tid-1].ac++;
                teams[tid-1].pen += wa_cnt[tid][pid] * 1200 + time;
                aced[tid][pid] = true;
            }else{
                wa_cnt[tid][pid]++;
            }
        }
        sort(teams.begin(), teams.end());
        for(int i=0;i<t;i++){
            cout << teams[i].num << " " << teams[i].ac << " " << teams[i].pen << endl;
        }
    }
}

C++: #include <iostream>
#include <deque>
#include <map>
#include <queue>

using namespace std;

typedef int teamID;

struct TeamResult
{
    int id;
    int correctCount;
    int penalty;
};

struct ICPCResult
{
    map<teamID, TeamResult> tResult;
};

struct ProblemStatus
{
    bool clear;
    int wrongCount;
};

struct TeamStatus
{
    typedef int problemID;
    map<problemID, ProblemStatus> pStatuses;
};

struct MyComp : public binary_function<TeamResult, TeamResult, bool>
{
    bool operator()(const TeamResult& x, const TeamResult& y) const
    {
        if (x.correctCount > y.correctCount) return false;
        if (x.correctCount == y.correctCount)
        {
            if (x.penalty < y.penalty) return false;
            if (x.penalty == y.penalty) return x.id > y.id;
        }
        return true;
    }
};

int main()
{
    deque<ICPCResult> results;
    string result;
    int T, P, R;
    while (cin >> T >> P >> R)
    {
        if (T == 0 && T == 0 && R == 0) break;
        results.push_back(ICPCResult());
        ICPCResult& curICPCResult = results.back();
        map<teamID, TeamStatus> tStatuses;
        for (int log = 0; log < R; ++log)
        {
            int tID, pID, time;
            string msg;
            cin >> tID >> pID >> time >> msg;
            ProblemStatus& thisProblemStatus = tStatuses[tID].pStatuses[pID];
            if (msg == "CORRECT")
            {
                TeamResult& thisTeamResult = curICPCResult.tResult[tID];
                thisTeamResult.id = tID;
                ++thisTeamResult.correctCount;
                thisTeamResult.penalty += thisProblemStatus.wrongCount*1200 + time;
            }
            else ++thisProblemStatus.wrongCount;
        }
        
        priority_queue<TeamResult, vector<TeamResult>, MyComp> sorted;
        for (int tID = 1; tID <= T; ++tID)
        {
            TeamResult& tResult = curICPCResult.tResult[tID];
            tResult.id = tID;
            sorted.push(tResult);
        }
        
        while (sorted.size() != 0)
        {
            const TeamResult& team = sorted.top();
            char buf[256];
            sprintf(buf, "%d %d %d\n", team.id, team.correctCount, team.penalty);
            result += buf;
            sorted.pop();
        }
    }
    cout << result << endl;
}