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 <string>
#include <vector>
#include <algorithm>
using namespace std;

struct P{
    int team;
    int ans;
    int sum;
    int pro[100];
    static bool less(const P& left,const P& right){
        return left.team < right.team;
    }
    static bool point(const P& pleft,const P& pright){
        return pleft.sum < pright.sum;
    }
    static bool more(const P& mleft,const P& mright){
        return mleft.ans > mright.ans;
    }
};

int main(){
    int t,p,r,tid,pid,tim;
    string sta;
    while(cin >> t >> p >> r){
        if(t == 0 && r == 0 && p == 0) break;
        vector <P> data;
        P tmp;
        for(int i=0;i<t;i++){
            tmp.team = i+1;
            tmp.ans = 0;
            tmp.sum = 0;
            for(int j=0;j<=p;j++) tmp.pro[j] = 0;
            data.push_back(tmp);
        }
        while(r--){
            cin >> tid >> pid >> tim >> sta;
            if(sta == "CORRECT"){
                for(int i=0;i<t;i++){
                    if(data[i].team == tid){
                        data[i].sum += data[i].pro[pid]*1200+tim;
                        data[i].ans += 1;
                        break;
                    }
                }
            }
            else if(sta == "WRONG"){
                for(int i=0;i<t;i++){
                    if(data[i].team == tid) data[i].pro[pid] += 1;
                }
            }
        }
        sort(data.begin(),data.end(),P::less);
        sort(data.begin(),data.end(),P::point);
        sort(data.begin(),data.end(),P::more);
        for(int i=0;i<t;i++) cout << data[i].team << " " << data[i].ans << " " << data[i].sum << endl;
    }
}

C++: #define _CRT_SECURE_NO_WARNINGS // #pragma warning(disable:4996)
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <functional>
#include <sstream>
#include <cmath>
#include <set>
#include <map>
#include <stack>
using namespace std; 

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define all(a) a.begin(),a.end()
#define len(x) ((int)(x).size())
#define tmax(a,b,c) max((a),max((b),(c)))
#define tmin(a,b,c) min((a),min((b),(c)))
#define debug(x) cerr << #x << " is " << x << endl;

typedef pair<int, int> Pii;
typedef map<int, int> Mii;
typedef vector<int> Vi;
typedef long long ll;
const int inf = 2e9;
const ll ll_inf = 1e17;
const int mod = 1e9 + 7;
const long double eps = 1e-10;

struct team
{
	int id;
	int pen = 0;
	int cor = 0;
	int cnt[11] = {};
	bool f[11] = {};
};

bool operator<(team& lhs, team& rhs) {
	if (lhs.cor == rhs.cor)
		return lhs.pen < rhs.pen;
	else
		return lhs.cor > rhs.cor;
}

int main()
{
	while (1) {
		int t, p, r;
		cin >> t >> p >> r;
		if (!t && !p && !r) break;
		team ts[51];
		rep(i,0,t) ts[i].id = i+1;
		rep(i, 0, r) {
			int a, b, c;
			string s;
			cin >> a >> b >> c >> s;
			a--; b--;
			if (ts[a].f[b]) continue;
			if (s == "CORRECT") {
				ts[a].cor++;
				ts[a].pen += 1200 * ts[a].cnt[b] + c;
			}
			else {
				ts[a].cnt[b]++;
			}
		}
		sort(ts, ts+t);
		rep(i,0,t) cout << ts[i].id << " " << ts[i].cor << " " << ts[i].pen << endl;
	}
	return 0;
}

C++: #include<stdio.h>
#include<algorithm>
using namespace std;
pair<pair<int,int> ,int> t[50];
int d[50][10];
char str[10];
int main(){
	int a,b,c;
	while(scanf("%d%d%d",&a,&b,&c),a){
		for(int i=0;i<50;i++)t[i]=make_pair(make_pair(0,0),i+1);
		for(int i=0;i<50;i++)
			for(int j=0;j<10;j++)
				d[i][j]=0;
		for(int i=0;i<c;i++){
			int p,q,r;
			scanf("%d%d%d%s",&p,&q,&r,str);
			p--;q--;
			if(str[0]=='W')d[p][q]++;
			else{
				t[p].first.first--;
				t[p].first.second+=1200*d[p][q]+r;
			}
		}
		std::sort(t,t+a);
		for(int i=0;i<a;i++)printf("%d %d %d\n",t[i].second,-t[i].first.first,t[i].first.second);
	}
}

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]);
          break;
        }
      }
    }

    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]);
          break;
        }
      }
    }

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

  }

  return 0;
}