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 <string.h>

typedef struct {
    int ID;
    int penalty;
    int solved;
} set;

set team[51];
int i, j;
int wrong[51][11];
int tID, pID, time;
int T, P, R;
char mes[10];
int count;

int max_solved, min_penalty, winner;

void findfirst(void);

int main(void)
{
    while(1) {
	scanf("%d %d %d", &T, &P, &R);
	if (T == 0) break;
	for (i = 1; i <= T; i++) {
	    team[i].ID = i;
	    team[i].penalty = 0;
	    team[i].solved = 0;
	    for (j = 1; j <= P; j++) {
		wrong[i][j] = 0;
	    }
	}
	for (i = 0; i < R; i++) {
	    scanf("%d %d %d %s", &tID, &pID, &time, mes);
	    if (mes[0] == 'W') {
		wrong[tID][pID]++;
	    } else {
		team[tID].solved++;
		team[tID].penalty += 1200 * wrong[tID][pID] + time;
	    }
	}
	max_solved = T + 1;
	min_penalty = - 1;
	winner = 0;
	for (count = 0; count < T; count++) {
	    findfirst();
	    printf("%d %d %d\n", winner, team[winner].solved, team[winner].penalty);
	    max_solved = team[winner].solved;
	    min_penalty = team[winner].penalty;
	}
    }
    return 0;
}

void findfirst(void)
{
    int winner_solved = -1;
    int winner_penalty = 1200 * 500 + 10800 * 500;
    int winner_team;
    int winner_candidate[51];

    for (i = 1; i <= T; i++) {
	if (team[i].solved > winner_solved && (team[i].solved < max_solved || (team[i].solved == max_solved && team[i].penalty > min_penalty) || (team[i].solved == max_solved && team[i].penalty == min_penalty && i > winner))) {
	    winner_solved = team[i].solved;
	    winner_team = i;
	}
    }
    j = 0;
    for (i = winner_team; i <= T; i++) {
	if (team[i].solved == team[winner_team].solved) {
	    winner_candidate[j] = i;
	    j++;
	}
    }
    for (i = 0; i < j; i++) {
	if (team[winner_candidate[i]].penalty < winner_penalty) {
	    winner_penalty = team[winner_candidate[i]].penalty;
    	    winner = winner_candidate[i];
	}
    }
}

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

#define rep2(i, b, n) for(int i=b; i < n; ++i)
#define rep(i, n) rep2(i, 0, n)

using namespace std;

struct team {
	int id;
	int time;
	int accept;
	int wrong[10];
};

bool operator<( const team &a, const team &b )
{
	if(a.accept > b.accept) return true;
	else if(a.accept < b.accept) return false;
	else {
		if(a.time < b.time) return true;
		else if(a.time > b.time) return false;
		else {
			if(a.id < b.id) return true;
			else return false;
		}
	}
	return false;
}

int main( void )
{
	int t, p, r;
	team T[50];
	while(cin >> t >> p >> r, t | p | r) {
		rep(i, t) {
			T[i].id = i+1;
			T[i].time = 0;
			T[i].accept = 0;
			rep(j, p) T[i].wrong[j] = 0;
		}
		rep(i, r) {
			int id, no, tm;
			string msg;
			cin >> id >> no >> tm >> msg;
			--id; --no;
			if(msg[0] == 'W')
				++T[id].wrong[no];
			else { // msg[0] == 'C'
				T[id].time += (tm + T[id].wrong[no]*1200);
				++T[id].accept;
			}
		}
		sort(T, T+t);
		rep(i, t)
			cout << T[i].id << ' ' << T[i].accept << ' ' << T[i].time << endl;
	}
	return 0;
}

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

struct team{
  int ans,id,pena;
  int p[10];
  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(r==0)return 0;
    int tid,tm,pid;
    string mes;
    team T[t];
    for(int i=0;i<t;i++){
      T[i].id=i+1;
      T[i].ans=0;
      T[i].pena=0;
      for(int j=0;j<10;j++)T[i].p[j]=0;
    }
    for(int i=0;i<r;i++){
      cin>>tid>>pid>>tm>>mes;
      tid--;pid--;
      if(mes=="CORRECT"){
	T[tid].ans++;
	T[tid].pena+=T[tid].p[pid]*1200 + tm;
      }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 fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define fth(t) std::get<3>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P3 = std::tuple<int,int,int>;

const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0, 0, -1, 1, -1, 1, -1, 1};

P3 ps[60];
bool solved[60][20];
int WAs[60][20];

int main(){
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    while(true){
        int T, P, R;
        std::cin >> T >> P >> R;
        if(!T){break;}
    
        for(int i=1;i<=T;++i){
            ps[i] = std::make_tuple(0, 0, 0);
        }
        memset(solved, 0, sizeof(solved));
        memset(WAs, 0, sizeof(WAs));
    
        for(int i=0;i<R;++i){
            int tid, pid, t;
            string message;

            std::cin >> tid >> pid >> t >> message;

            if(solved[tid][pid]){continue;}
            if(message == "CORRECT"){
                ++fst(ps[tid]);
                snd(ps[tid]) += WAs[tid][pid] * 1200 + t;
                solved[tid][pid] = true;
            }else{
                ++WAs[tid][pid];
            }
        }

        for(int i=1;i<=T;++i){
            fst(ps[i]) = -fst(ps[i]);
            thd(ps[i]) = i;
        }

        sort(ps+1, ps+1+T);

        for(int i=1;i<=T;++i){
            std::cout << thd(ps[i]) << " " << (-fst(ps[i])) << " " << snd(ps[i]) << std::endl;
        }
    }
}