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<algorithm>
#include<cstdio>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<cstring>
#include<cstdlib>
#include<cctype>
#include<bitset>
#include<functional>
#include<climits>
using namespace std;
typedef pair<int,int>pii;
const int INF=1e9;
const int dx[]={0,-1,0,1},dy[]={-1,0,1,0};

struct data{
    int cnt,m,id;
    data(int a,int b,int c):cnt(a),m(b),id(c){}
    data(){}
    bool operator<(const data &d)const{
        if(cnt!=d.cnt)return cnt<d.cnt;
        if(m!=d.m)return m>d.m;
        return id>d.id;
    }
};

int main(){
    int t,p,r;
    while(cin>>t>>p>>r,t||p||r){
        bool ac[50][10];fill_n(*ac,500,false);
        int wa[50][10];fill_n(*wa,500,0);
        vector<data>D(t);
        for(int i=0;i<t;i++){
            D[i]=data(0,0,i);
        }
        while(r--){
            int tid,pid,tm;
            string mes;
            cin>>tid>>pid>>tm>>mes;
            tid--;
            pid--;
            if(ac[tid][pid])continue;
            if(mes=="CORRECT"){
                ac[tid][pid]=true;
                D[tid].cnt++;
                D[tid].m+=tm+1200*wa[tid][pid];
            }
            else wa[tid][pid]++;
        }
        sort(D.rbegin(),D.rend());
        for(int i=0;i<t;i++){
            data x=D[i];
            cout<<x.id+1<<" "<<x.cnt<<" "<<x.m<<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 penalty[t][r];
        rep(i, t)rep(j, r){penalty[i][j] = 0; correct[i][j] = false;}
        rep(k, r){
            int team, problem, time;
            string message;

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

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

        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<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(mes=="CORRECT" && T[i].p[pid]!=-1){
	T[tid].ans++;
	T[tid].pena+=T[tid].p[pid]*1200 + tm;
	T[i].p[pid]=-1;
      }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;

int T;
int P;
int R;
char msg[114514];
int penalty[1145];
int correct[1145];
int teams[1145];
int wrong[1145][1419];

bool Compare(int a, int b) {
  if (correct[a] != correct[b]) return correct[a] > correct[b];
  return penalty[a] < penalty[b];
}

int main() {
  while (1) {
    scanf("%d%d%d", &T, &P, &R);
    if ((T|P|R) == 0) return 0;

    for (int i=0; i<T; i++) teams[i] = i+1;
    fill(wrong[0], wrong[110], 0); 
    fill(correct, correct+110, 0); 
    fill(penalty, penalty+110, 0); 
  
    for (int i=0; i<R; i++) {
      int tid, pid, time;
      scanf("%d%d%d %s", &tid, &pid, &time, msg);
  
      string s(msg);
      if (s == "WRONG") {
        wrong[tid][pid] += 1;
      } else {
        penalty[tid] += wrong[tid][pid] * 1200 + time;
        correct[tid]++;
      }
    }
  
    sort(teams, teams+T, Compare);
    for (int i=0; i<T; i++) {
      int d = teams[i];
      printf("%d %d %d\n", d, correct[d], penalty[d]);
    }
  }
}