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 <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 30;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

struct Team{
  vi wa;
  int num;
  int ac;
  int time;

  void init(int p, int i) {
    wa.resize(p, 0);
    num = i;
    ac = 0;
    time = 0;
  }

  void wrong(int p) {
    wa[p]++;
  }

  void correct(int p, int t) {
    ac++;
    time += t + 1200 * wa[p];
  }
};

bool operator>(const Team& t1, const Team& t2) {
  if(t1.ac == t2.ac) {
    if(t1.time == t2.time) {
      return t1.num < t2.num;
    } else {
      return t1.time < t2.time;
    }
  } else {
    return t1.ac > t2.ac;
  }
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  while(1) {
    int t, p, r; cin >> t >> p >> r;
    if(t == 0) break;
    vector<Team> team(t);
    REP(i, t) {
      team[i].init(p, i);
    }
    REP(i, r) {
      int t, p, time;
      string message;
      cin >> t >> p >> time >> message;
      if(message == "CORRECT") {
        team[t-1].correct(p-1, time);
      } else {
        team[t-1].wrong(p-1);
      }
    }
    sort(ALL(team), greater<Team>());

    REP(i, t) {
      cout << team[i].num+1 << " " << team[i].ac << " " << team[i].time << endl;
    }
  }
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstring>
#include<cstdio>
#include<cmath>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define onen(i,n) for(int i=1;i<n+1;i++)

const int MAXT = 51, MAXP = 11, MAXR = 500,MAXTIME = 10800;

int tid,pid,atime;
int t,p,r;
string message ;
int ac[MAXT], wa[MAXT][MAXP], pena[MAXT];
bool used[MAXT];
typedef pair<int, int> pp;

int main()
{
    while(cin >> t >> p >> r && t)
    {
        //初期化
        memset(ac, 0, sizeof(ac));
        memset(wa, 0, sizeof(wa));
        memset(used, false , sizeof(used));
        memset(pena, 0, sizeof(pena));
        
        //入力
        REP(r)
        {
            cin >> tid >> pid >> atime >> message;
            if(message == "WRONG")
                wa[tid][pid]++;

            else
            {
                ac[tid]++;
                pena[tid] += (wa[tid][pid] * 1200 + atime);
            }
        }

        rep(j,t)
        {
            int topacc = -1, topp = 100000,top = 0;
            onen(i,t)if(!used[i] &&(topacc < ac[i] || (topacc == ac[i] && topp > pena[i]))) //まだ出してなくて，acが今のtopより多いか，acが同じでpenaが大きい奴でtopを更新
            {
                top = i;
                topacc = ac[i];
                topp = pena[i];
            }
            used[top] = true;
            cout << top << " " << topacc << " " << topp << endl;
        }
    }

    return 0;
}

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

int t, p, r, tID, pID, times;
int point[100], wrong[100][100], penalty[100], ans[100];
string message;

bool AC_comp(const int &a, const int &b){
    if(point[a] == point[b]){
	if(penalty[a] == penalty[b])
	    return return a < b;
	return penalty[a] < penalty[b];
    }
    return point[a] > point[b];
}

int main(){
    while(true){
	cin >> t >> p >> r;
	if(t == 0 && p == 0 && r == 0)return 0;
	memset(point, 0, sizeof(point));
	memset(penalty, 0, sizeof(penalty));
	memset(wrong, 0, sizeof(wrong));
	for(int i = 0;i < r;i++){
	    cin >> tID >> pID >> times >> message;
	    if(message == "CORRECT"){
		point[tID]++;
		penalty[tID] += times + wrong[tID][pID] * 1200;
	    }
	    else{
		wrong[tID][pID]++;
	    }
	}
	for(int i = 0;i < t;i++){
	    ans[i] = i + 1;
	}
	sort(ans, ans + t, AC_comp);
	for(int i = 0;i < t;i++){
	    int team = ans[i];
	    cout << team << ' ' << point[team] << ' ' << penalty[team] << endl;
	}
    }
}

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

struct AWT{
    int ac;
    int wa;
    int t_id;
    bool operator<(const AWT &another)const{
        if(ac!=another.ac){
            return ac > another.ac;
        }else if(wa!=another.wa){
            return wa < another.wa;
        }else{
            return t_id < another.t_id;
        }
    }
};

int main(){

    while(1){
        int T,P,R;
        cin >> T >> P >> R;
        if(T==0&&P==0&&R==0)break;
        vector<AWT> awt(T);
        vector<vector<int>> pen(T,vector<int>(P,0));
        for(int i=0;i<T;i++){
            awt[i].ac=0;
            awt[i].wa=0;
            awt[i].t_id=i+1;
        }
        for(int i=0;i<R;i++){
            int tid,pid,t;
            string msg;
            cin >> tid >> pid >> t >> msg;
            tid--;pid--;
            if(msg=="WRONG"){
                pen[tid][pid]++;
            }else{
                awt[tid].ac++;
                awt[tid].wa+=t+1200*pen[tid][pid];
            }
        }
        sort(awt.begin(),awt.end());
        for(int i=0;i<T-1;i++){
            cout << awt[i].t_id << " " << awt[i].ac << " " << awt[i].wa << endl;
        }
        cout << awt.back().t_id << " " << awt.back().ac << " " << awt.back().wa << endl;
    }

    return 0;
}