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

using namespace std;

bool isSolved[101][101];
int pena[101][101];
int solvedCnt[101];
int teamPena[101];

typedef pair<int,int> pii;
typedef pair<pii,int> ppii;

int main(){
  int T,P,R;
  while(cin>>T>>P>>R&&(T|P|R)){
    memset(isSolved,0,sizeof(isSolved));
    memset(pena,0,sizeof(pena));
    memset(solvedCnt,0,sizeof(solvedCnt));
    memset(teamPena,0,sizeof(teamPena));
    for(int i=0;i<R;i++){
      int tid,pid,time;
      string msg;
      cin>>tid>>pid>>time>>msg;
      if(msg=="WRONG"){
	pena[tid][pid]++;
      }
      else if(!isSolved[tid][pid]){
	isSolved[tid][pid]=true;
	solvedCnt[tid]++;
	teamPena[tid]+=pena[tid][pid]*1200+time;
      }
    }
    vector<ppii> vp;
    for(int i=1;i<=T;i++){
      vp.push_back(make_pair(pii(-solvedCnt[i]
				 ,teamPena[i]),i));
    }
    sort(vp.begin(),vp.end());
    for(int i=0;i<(int)vp.size();i++){
      cout<<vp[i].second<<" "<<-vp[i].first.first<<" "<<vp[i].first.second<<endl;
    }
  }

  return 0;
}

C++: #include<bits/stdc++.h>
#define endl '\n';
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int T,p,R;
    cin >> T >> p >> R;
    while(T != 0){
        vector<pair<int,pair<int,int>>> G(T);
        for(int i=0; i<T; i++){
            G[i].second.second = i;
        }
        vector<vector<int>> cnt(T,vector<int> (p,0));
        for(int i=0; i<R; i++){
            int tid,pid,time;
            string message;
            cin >> tid >> pid >> time >> message;
            tid--;
            pid--;
            if(cnt[tid][pid] == -1) continue;
            if(message == "CORRECT"){
                G[tid].first--;
                G[tid].second.first += time+1200*cnt[tid][pid];
                cnt[tid][pid] = -1;
            }else{
                cnt[tid][pid]++;
            }
        }
        sort(G.begin(),G.end());
        for(int i=0; i<T; i++){
            cout << G[i].second.second+1 << " " << -G[i].first << " " << G[i].second.first << endl;
        }
        cin >> T >> p >> R;
    }
    return 0;
}

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

struct team{
  int ans,id,p[10],pena;
  bool operator<(const team &a)const{
    if(this->ans == a.ans){
      return this->pena < a.pena;
    }else{
      return this->ans > a.ans;
    }
  }
};

int main(){
  int t,p,r;
  while(cin>>t>>p>>r){
    if(t==0)return 0;
    team T[t];
    memset(T,0,sizeof(T));
    for(int i=0;i<t;i++)T[i].id=i+1;

    int tid,tm,pid;
    string mes;
    for(int i=0;i<r;i++){
      cin>>tid>>pid>>tm>>mes;
      tid--;pid--;
      if(T[tid].p[pid]<0)continue;
      if(mes=="CORRECT"){
	T[tid].ans++;
	T[tid].pena+=T[tid].p[pid]*1200 + tm;
	T[tid].p[pid]=-10;
      }else{
	T[tid].p[pid]++;
      }
    }
    sort(T,T+t);
    for(int i=0;i<t;i++)
      cout << T[i].id << " " << T[i].ans << " " << T[i].pena << endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)

int main(){
	while(1){
		int t,p,r;
		cin>>t>>p>>r;
		if(t==0&&p==0&&r==0) break;
		int qstats[55][15];
		int score[55],pn[55];
		lp(i,55){
			score[i]=0;
			pn[i]=0;
			lp(j,15){
				qstats[i][j]=0;
			}
		}
		lp(i,r){
			int a,b,c;
			string d;
			cin>>a>>b>>c>>d;
			if(d=="CORRECT"){
				score[a]++;
				pn[a]+=c+qstats[a][b]*1200;
			}
			else{
				qstats[a][b]++;
			}
		}
		tuple<int,int,int> ans[50];
		lp(i,t){
			ans[i]=make_tuple(score[i+1],-pn[i+1],500-i-1);
		}
		sort(ans,ans+t);
		reverse(ans,ans+t);
		lp(i,t){
			int ans1,ans2,ans3;
			ans1=get<2>(ans[i]);
			ans2=get<0>(ans[i]);
			ans3=get<1>(ans[i]);
			cout<<500-ans1<<" "<<ans2<<" "<<-ans3<<endl;
		}
	}
	return 0;
}

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

#define pb         push_back

const int INF = 1000000000;
const int MOD = 1000000007;

typedef struct _team{
	int tid;
	int solve;
	int wr[100] = {};
	int pen;
}Team;

bool CmpSolve(const Team& a, const Team& b){
	return (a.solve == b.solve) ? a.pen < b.pen : a.solve > b.solve ;
}

int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);

	while(1){
		int t, p, r;
		cin >> t >> p >> r;
		if(t == 0 && p == 0 && r == 0) break;

		vector<Team> teams;

		for(int i=1; i<=t; i++){
			Team tmp;
			tmp.tid = i;
			tmp.solve = 0;
			tmp.pen = 0;
			teams.push_back(tmp);
		}

		for(int i=0; i<r; i++){
			int tid, pid, time;
			string mes;
			cin >> tid >> pid >> time >> mes;
			tid--;

			if(mes == "WRONG"){
				teams[tid].wr[pid]++;
			}else if(mes == "CORRECT"){
				teams[tid].solve++;
				teams[tid].pen += teams[tid].wr[pid]*1200 + time;
			}
		}

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

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

	}
	

	return 0;
}