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 <cstdio>
#include <iostream>
#include <vector>
#include <functional>
#include <numeric>
#include <string>
#include <iterator>
#include <sstream>
#include <map>
#include <set>
#include <utility>
#include <algorithm>
#include <cstring>

using namespace std;

struct TEAM{
	int cnt,pt,id;

	bool operator < (const TEAM& x) const{
		if(cnt != x.cnt) return greater<int>()(cnt,x.cnt);
		if(pt != x.pt) return less<int>()(pt,x.pt);
		return false;
	}
};


bool co[55][10];
int w_cnt[55][10];


int main()
{
	int T,P,R;
	while(cin>>T>>P>>R,(T||P||R)){
		vector<TEAM> team(T);
		for(int i = 0; i < T; i++){
			team[i].id = i + 1;
		}
		memset(co,0,sizeof(co));
		memset(w_cnt,0,sizeof(w_cnt));
		for (int i = 0; i < R; i++){
			int ti,pi,time; string s;
			cin>>ti>>pi>>time>>s;
			if(co[ti][pi]) continue;
			if(s[0] == 'W'){
				w_cnt[ti][pi]++; continue;
			}
			team[ti - 1].cnt++;
			team[ti - 1].pt += time + w_cnt[ti][pi] * 1200;
		}

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

		for (int i = 0; i < T; i++){
			printf("%d %d %d\n",team[i].id,team[i].cnt,team[i].pt);
		}
	}

	return 0;
}

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

using namespace std;

struct Team
{
    int id, cnt, time;
    vector<bool> b;
    vector<int> es;
};


int main()
{
    int T, P, R;
    while(cin >> T >> P >> R, T){
        vector<Team> ts{};
        
        for(int i=0;i<T;++i){
            Team t = {i+1, 0, 0, vector<bool>(P, false), vector<int>(P, 0)};
            ts.emplace_back(move(t));
        }
        
        for(int i=0;i<R;++i){
            int tid, pid, time;
            string msg;
            cin >> tid >> pid >> time >> msg;
            auto& t = ts[tid-1];
            if(msg == "CORRECT"){
                t.b[pid-1] = true;
                t.time += t.es[pid-1]*1200 + time;
                t.cnt += 1;
            }else{
                t.es[pid-1] += 1;
            }
        }
        
        sort(ts.begin(), ts.end(), [&](Team const& t1, Team const& t2){
            if(t1.cnt == t2.cnt){
                if(t1.time == t2.time) return t1.id < t2.id;
                else return t1.time < t2.time;
            }else return t1.cnt > t2.cnt;
        });
        
        for(auto& e: ts){
            cout << e.id << ' ' << e.cnt << ' ' << e.time << endl;
        }
    }
}

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


struct team{
	  int  id, c, p;
	  vector<int> w;
	  team(int i, int correct, int pena, int num_pro){
			id = i; c = correct; p = pena; w = vector<int>(num_pro+1,0);
	  }
	  bool operator < (const team& tgt) const {
			if(c != tgt.c) return c < tgt.c;
			if(p != tgt.p) return p > tgt.p;
			return id > tgt.id;
	  }
};

int main(){
	  
	  while(1){
			int t,p,r; cin >> t >> p >> r;
			if(!t) break;

			vector<team> teams;
			teams.push_back( team(10000,-1,1000000,10) );
			for(int i=1; i<=t; i++)
				  teams.push_back( team(i,0,0,p) );
			
			for(int i=0; i<r; i++){
				  int tid,pid,time;
				  string m;
				  cin >> tid >> pid >> time >> m;

				  if(m == "CORRECT"){
						teams[tid].c ++;
						teams[tid].p += teams[tid].w[pid] * 1200 + time;
				  }
				  else{
						teams[tid].w[pid]++;
				  }
			}
			sort(teams.begin(),teams.end());
			reverse(teams.begin(),teams.end());
			for(int i=0; i<t; i++)
				  cout << teams[i].id << " " << teams[i].c << " " << teams[i].p << endl;
				  
	  }
	  
}

C++: #define _CRT_SECURE_NO_WARNINGS // #pragma warning(disable:4996)
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <functional>
#include <sstream>
#include <cmath>
#include <set>
#include <map>
#include <stack>
using namespace std; 

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define all(a) a.begin(),a.end()
#define len(x) ((int)(x).size())
#define tmax(a,b,c) max((a),max((b),(c)))
#define tmin(a,b,c) min((a),min((b),(c)))
#define debug(x) cerr << #x << " is " << x << endl;

typedef pair<int, int> Pii;
typedef map<int, int> Mii;
typedef vector<int> Vi;
typedef long long ll;
const int inf = 2e9;
const ll ll_inf = 1e17;
const int mod = 1e9 + 7;
const long double eps = 1e-10;

struct team
{
	int id;
	int pen = 0;
	int cor = 0;
	int cnt[11] = {};
	bool f[11] = {};
};

bool operator<(team& lhs, team& rhs) {
	if (lhs.cor == rhs.cor)
		return lhs.pen < rhs.pen;
	else
		return lhs.cor > rhs.cor;
}

int main()
{
	while (1) {
		int t, p, r;
		cin >> t >> p >> r;
		if (!t && !p && !r) break;
		team ts[51];
		rep(i,0,t) ts[i].id = i+1;
		rep(i, 0, r) {
			int a, b, c;
			string s;
			cin >> a >> b >> c >> s;
			a--; b--;
			if (ts[a].f[b]) continue;
			if (s == "CORRECT") {
				ts[a].cor++;
				ts[a].pen += 1200 * ts[a].cnt[b] + c;
			}
			else {
				ts[a].cnt[b]++;
			}
		}
		sort(ts, ts+t);
		rep(i,0,t) cout << ts[i].id << " " << ts[i].cor << " " << ts[i].pen << endl;
	}
	return 0;
}