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;

/*struct hoge{
  bool operator()(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);
    int fail[11][11] = {};
    int tid, pid, time;
    char message[16];
    rep(i, T) t[i].first = i+1;     
    rep(i, R){
      scanf("%d%d%d%s", &tid, &pid, &time, message); tid--; pid--;
      if(message[0] == 'C'){
	if(fail[tid][pid] != -1){
	  t[tid].second.first++;
	  t[tid].second.second += fail[tid][pid] * 1200 + time;
	  fail[tid][pid] = -1;
	}
      }else if(message[0] == 'W'){
	if(fail[tid][pid] != -1)
	  fail[tid][pid]++;
      }
    }
    sort(t.begin(), t.end());
    rep(i, T) printf("%d %d %d\n", t[i].first, t[i].second.first, t[i].second.second);
  }
  return 0;
}

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

typedef struct TreamInfo
{
    int tID;
    int points;
    int pena;
    int ProbMiss[10];

    TreamInfo(int tid) : tID(tid) {}
} TeamInfo;

bool cmp(const TeamInfo &a, const TeamInfo &b)
{
    return (a.points == b.points)?(a.pena == b.pena? a.tID < b.tID:a.pena < b.pena):(a.points > b.points);
}

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

        vector<TeamInfo> v;

        for (size_t i = 0; i < t; i++)
        {
            v.push_back(TeamInfo(i+1));
        }

        for (size_t i = 0; i < r; i++)
        {
            int tID, pID, tim;
            string mess;
            cin >> tID >> pID >> tim >> mess;

            if (mess == "CORRECT")
            {
                v[tID - 1].points += 1;
                v[tID - 1].pena += ((v[tID - 1].ProbMiss[pID - 1]) * 1200) + tim;
            }
            if (mess == "WRONG")
            {
                v[tID - 1].ProbMiss[pID - 1] += 1;
            }
        }
        // for (size_t i = 0; i < t; i++)
        // {
        //     cout << "team " << i <<" point is " <<v[i].points << endl;
        //     cout << "team " << i << " pena is " << v[i].pena << endl;
        // }

        sort(v.begin(), v.end(), cmp);
        // for (size_t i = 0; i < t; i++)
        // {
        //     cout << v[i].tID <<" "<< v[i].points <<" "<< v[i].pena << endl;
        // }
    }
    return 0;
}

C++: #include <vector>
#include <iostream>
#include <string>
#include <algorithm>
#include <tuple>
#define REP(i,n) for(int i=0;i<(n);i++)
#define P pair<int,int>
using namespace std;

bool compare(tuple<int,int,int> a, tuple<int,int,int> b){
	if(get<0>(a) == get<0>(b)){
			if(get<1>(a) == get<1>(b)){
				return get<2>(a) < get<2>(b);
			}
			return get<1>(a) < get<1>(b);
		}
		return get<0>(a) > get<0>(b);
}
			
int main(){
	int t,p,r;
	while(cin>>t>>p>>r,t){
		vector<tuple<int,int,int> > inf_team(t,tuple<int,int,int>(0,0,0));//problem,time,number
		REP(i,t)get<2>(inf_team[i]) = i;
		vector<vector<int> > penalty(t,vector<int>(p,0));
		REP(i,r){
			int t_id,p_id,time;
			string mes;
			cin >> t_id >> p_id >> time >> mes;
			t_id--;p_id--;
			if(mes=="WRONG"){
				penalty[t_id][p_id]++;
			}else{
				get<1>(inf_team[t_id]) += time + 1200*penalty[t_id][p_id];
				get<0>(inf_team[t_id])++;
			}
		}
		sort(inf_team.begin(),inf_team.end(),compare);
		REP(i,t){
			cout << get<2>(inf_team[i]) + 1 << " " << get<0>(inf_team[i]) << " " << get<1>(inf_team[i]) << endl;
		}
	}
	return 0;
}

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

int main(){
  int T,P,R,ttid,tpid,ttime,t;
  int solved[50];
  int wrong[50][10];
  int tpenum[50];
  int rk[50];
  char buf[10];
  while(1){
    for (int i=0;i<50;i++){
      solved[i]=0;
      tpenum[i]=0;
      rk[i]=i;
      for (int j=0;j<10;j++) wrong[i][j]=0;
    }
    
    cin >> T >> P >> R;

    if (T==0&&P==0&&R==0) break;

    for (int i=0;i<R;i++){
      cin >> ttid >> tpid >> ttime >> buf;
      ttid--;
      tpid--;
      if (buf[0]=='C'){
	solved[ttid]++;
	tpenum[ttid]+=wrong[ttid][tpid]*1200+ttime;
      }else{
	wrong[ttid][tpid]++;
      }
    }

    // for (int i=0;i<T;i++){
    //  for (int j=0;j<P;j++){
    //	tpenum[i]+=penum[i][j];
    //    }
    // }
    for (int i=0;i<T;i++){
      for (int j=T-1;j>i;j--){
	//	cout << j << rk[j]<< rk[j-1]<<solved[rk[j]]<<solved[rk[j-1]] <<endl;
	if (solved[rk[j]]>solved[rk[j-1]]){
	  // cout << "c" <<endl;
	  t=rk[j];
	  rk[j]=rk[j-1];
	  rk[j-1]=t;
	}else if (solved[rk[j]]==solved[rk[j-1]]){
	  if (tpenum[rk[j]]<tpenum[rk[j-1]]){
	    t=rk[j];
	    rk[j]=rk[j-1];
	    rk[j-1]=t;
	  }
	}
      }
    }

    for (int i=0;i<T;i++)cout << rk[i]+1 << " " << solved[rk[i]] << " " << tpenum[rk[i]] << endl;

  }
  return 0;
}