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<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 <iostream>
#include <iomanip>
#include <sstream>
#include <stdio.h>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
#include <utility>
#include <string>
#include <ctype.h>
#include <cstring>
#include <cstdio>
#include <sstream>
#include <functional>

using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ll long long
#define SORT(v) sort((v).begin(),(v).end())
//#define scanf scanf_s

struct team{ int ac, pe, t; };

bool comp(const team& t1, const team& t2)
{
	if (t1.ac != t2.ac) return t1.ac > t2.ac;
	else return t1.pe < t2.pe;
}

int main()
{
	int t, p, r;
	int rec[55][11][2];
	while (cin >> t >> p >> r, t)
	{
		memset(rec, 0, sizeof(rec));
		int a, b, c;
		string d;
		REP(i, r)
		{
			cin >> a >> b >> c >> d;
			if (d == "CORRECT") rec[a][b][1] += rec[a][b][0] + c;
			else rec[a][b][0] += 1200;
		}
		vector<team> v;
		FOR(i, 1, t + 1)
		{
			int ac = 0;
			int pe = 0;
			FOR(j, 1, p + 1)
			{
				if (rec[i][j][1] != 0)
				{
					ac++;
					pe += rec[i][j][1];
				}
			}
			team tmp = { ac, pe, i };
			v.push_back(tmp);
		}
		sort(v.begin(), v.end(), comp);
		REP(i, v.size())
		{
			cout << v[i].t << " " << v[i].ac << " " << v[i].pe << endl;
		}
	}
	return 0;
}

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

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vbb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair

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

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

int main(){
    int t, p, r;
    while(cin >> t >> p >> r, t+p+r){
        bool correct[t][r];
        int submit[t][r];
        int penalty[t][r];
        rep(i, t)rep(j, r)penalty[i][j] = 0;
        rep(i, t)rep(j, r)submit[i][j] = 0;
        rep(i, t)rep(j, r)correct[i][j] = false;
        rep(k , r){
            int team, problem, time;
            string message;

            cin >> team >> problem >> time >> message;
            team--; problem--;

            if(correct[team][problem]) continue;
            else {
                if(message == "CORRECT"){
                    correct[team][problem] = true;
                    penalty[team][problem] += submit[team][problem]*1200+time;
                }
                submit[team][problem]++;
            }
        }

        vector<pair<int, pair<int, int> > > v(t);
        rep(i, t){
            int ca = 0, pn = 0;
            rep(j, p){
                if(correct[i][j])ca++;
                pn += penalty[i][j];
            }
            v[i] = mp(ca, mp(inf-pn, 100-i));
        }
        sort(all(v));

        for(int i=t-1; 0 <= i; i--){
           cout << 100- v[i].second.second+1 << " " << v[i].first << " " << inf-v[i].second.first << endl;
        }
    }
}

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

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

  while(cin>>t>>p>>r&&t|p|r){
    vector<pair<int, pair<int, int> > > team(t);
    vector<pair<int, int> > problem;

    // initialize
    for(int i=0;i<t;i++){
      team[i].first=0;
      team[i].second.first=0;
      team[i].second.second=i+1;
    }

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

      if(message=="WRONG"){
        problem.push_back(make_pair(pid, tid));
      }else{
        team[tid-1].first++;
        for(int j=0;j<problem.size();j++){
          if(problem[j].first==pid&&problem[j].second==tid){
            team[tid-1].second.first+=1200;
          }
        }
        team[tid-1].second.first+=time;
      }
    }

    sort(team.begin(), team.end(), greater<pair<int, pair<int, int> > >());

    for(int i=0;i<=t-1;i++){
      for(int j=i+1;j<=t-1;j++){
        if(team[i].first==team[j].first&&team[i].second.first>team[j].second.first){
          swap(team[i],team[j]);
        }
      }
    }

    for(int i=0;i<=t-1;i++){
      for(int j=i+1;j<=t-1;j++){
        if(team[i].first==team[j].first&&team[i].second.first==team[j].second.first&&team[i].second.second>team[j].second.second){
          swap(team[i],team[j]);
        }
      }
    }

    for(int i=0;i<t;i++){
      cout << team[i].second.second << " " << team[i].first << " " << team[i].second.first << endl;
    }

  }

  return 0;
}