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 rep(i,n) for (int (i)=(0);(i)<(int)(n);++(i))
using ll = long long;

int main() {
    int t, p, r;
    while (cin >> t >> p >> r, (t or p or r)) {
        int ac[t+1], wa[t+1][p+1], tm[t+1], wan[t+1];

        fill(ac, ac+t+1, 0);
        fill(tm, tm+t+1, 0);
        fill(wan, wan+t+1, 0);
        fill(wa[0], wa[t+1], 0);

        rep(i, r) {
            int td, pd, t;
            string st;
            cin >> td >> pd >> t >> st;
            td--;
            pd--;
            if (st == "WRONG") {
                wa[td][pd] += 1;
                wan[td] += 1;
            }
            else if (st == "CORRECT") {
                tm[td] += wa[td][pd] * 1200 + t;
                ac[td] += 1;
            }
        }

        rep(i, t) {

            bool ok=false;
            int a = 0;
            rep(i, t) {
                a = max(a, ac[i]);
            }
            int f=0, team=0;
            rep(i, t) {
                if (a == ac[i] and ac[i] != -1) {
                    f++;
                    team = i;
                }
            }
            if (f == 1) {
                cout << team+1 << ' ' << ac[team] << " " << tm[team] << endl;
                ok = true;
                ac[team] = -1;
                continue;
            }

            if (!ok) {

                int w=1e8;
                rep(i, t) {
                    if ( a == ac[i]) {
                        w = min(w, tm[i]);
                    }
                }

                int f=0, team=0;
                rep(i, t) {
                    if (w == tm[i] and ac[i] != -1) {
                        f++;
                        team = i;
                    }
                }

                if (f == 1) {
                    cout << team+1 << ' ' << ac[team] << " " << tm[team] << endl;
                    ok=true;
                    ac[team] = -1;
                    continue;
                }

                if (!ok) {
                    rep(i, t) {
                        if (a == ac[i] and w == tm[i]) {
                            cout << i+1 << ' ' << ac[i] << " " << tm[i] << endl;
                            ac[i] = -1;
                            break;
                        }
                    }
                }

            }

        }

    }
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <complex>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <stack>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <cassert>

using namespace std;

typedef long long ll;
typedef ll li;
typedef pair<int,int> PI;
#define EPS (1e-10L)
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define F first
#define S second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int)((a).size())
#define ALL(a) a.begin(),a.end()
#define FOR(it,a) for(__typeof(a.begin())it=a.begin();it!=a.end();++it)
void pkuassert(bool t){t=1/t;};

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

int t,p,r;

void solve(){
  map<int,PI> app;
  rep(i,t) app[i+1]=mp(0,0);
  map<PI,int> tr;
  set<PI> ok;
  rep(i,r){
    int tid,pi,ti;
    string s;
    cin >> tid >> pi >> ti >> s;
    if(ok.count(mp(tid,pi))) continue;
    if(s[0]=='W'){
      tr[mp(tid,pi)]++;
    }else{
      ++app[tid].F;
      app[tid].S+=ti+tr[mp(tid,pi)]*1200;
      ok.insert(mp(tid,pi));
    }
  }
  vector<pair<PI,int> > team;
  FOR(it,app) team.pb(mp(mp(-it->S.F,-it->S.S),it->F));
  sort(ALL(team));
  FOR(it,team) cout << it->S << ' ' << -it->F.F << ' ' << -it->F.S << endl;
}

int main(int argc, char *argv[])
{
  while(cin >> t >> p >> r && t|p|r) solve();
  return 0;
}

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

// bad knowhow
#define REP(i,n) for(long long i=0;i<(long long)n;++i)

struct Score {
	Score() {}
	Score(int c, int p) : collects(c), penalty(p) {}
	bool operator<(const Score & other) {
		if (collects == other.collects){
			if (penalty == other.penalty) return id < other.id;
			return penalty < other.penalty;
		}
		return collects > other.collects;
	}
	int collects;
	long long penalty;
	int id;
};

int wrong[50][10];
bool collect[50][10];
Score score[50];


int main() {
	while (true) {
		fill(score, score + 50, Score(0,0));
		fill(*collect, *collect + 500, false);
		fill(*wrong, *wrong + 500, 0);

		int t, p, r;
		cin >> t >> p >> r;
		if (t == 0) break;

		REP(i, t) score[i].id = i;

		REP(i, r) {
			int tid, pid, time;
			string message;
			cin >> tid >> pid >> time >> message;
			tid--; pid--;
			if (collect[tid][pid]) continue;
			if (message == "CORRECT") {
				score[tid].collects++;
				collect[tid][pid] = true;
				score[tid].penalty += wrong[tid][pid] * 1200 + time;
			} else {
				wrong[tid][pid]++;
			}
		}

		sort(score, score+t);
		REP(i, t) {
			cout << score[i].id + 1 << " " << score[i].collects << " " << score[i].penalty << endl;
		}
	}
}