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<map>
#include<vector>
#include<list>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<climits>
#include<ctime>
#include<cstring>

//FUNCTION
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define rep_split(tok,a_str,re) for(char *tok = strtok((char *)a_str.c_str(),re); tok != NULL; tok = strtok(NULL,re))

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

//CONSTANT
#define INF 2000000000000
#define MAX 246912

//DEBUG
#define BAR() cout << "----------------------------" << endl;
#define DUMP(v) (cerr << #v << ": " << v << endl)
#define PRINT(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

typedef struct team 
{
	int tID;
	int accept;
	int pena;

	bool operator<(const team& right) const {
			if (accept == right.accept) {
				if (pena == right.pena) {
					return tID < right.tID;
				}
				else {
					return pena < right.pena;
				}
			}
			else {
				return accept > right.accept;
			}
		}

} Team;


int main()
{
	int t=0, p=0, r=0;
	
	int tID, pID, time;
	string message;

	while(cin >> t >> p >> r && t && p && r)
	{
		int miss[t][p];
		bool isCorrect[t][p];
		Team team[t+1];

		REP(x, 1, t+1){
			team[x].accept=0;
			team[x].pena=0;
			team[x].tID=x;
			rep(y,p){ miss[x][y]=0; isCorrect[x][y] = false; }
		}

		rep(i,r)
		{
			cin >> tID >> pID >> time >> message;

			if(message == "CORRECT"){
				if(!isCorrect[tID][pID])
				{
					team[tID].accept++;
					team[tID].pena += miss[tID][pID]*1200+time;
					isCorrect[tID][pID] = true;
				}
			}else{
				miss[tID][pID]++;
			}
		}
		
		sort(team+1,team+t+1);
		REP(i,1,t+1)
		{
			cout << team[i].tID << " "  << team[i].accept << " "<< team[i].pena << endl;
		}
	}

}

C++: #include <iostream>
#include <algorithm>
#include <utility>
#include <cstring>
#include <string>
#include <vector>

using namespace std;

typedef struct record_{
	public:
	int c;
	int p;
	int id;
	record_(int a1,int a2,int a3){
		c=a1;p=a2;id=a3;
	}
}record;

bool cmp(record a,record b){
	if(a.c > b.c)return true;
	if(a.c==b.c && a.p < b.p)return true;
	if(a.c==b.c && a.p==b.p &&  a.id < b.id)return true;
	return false;
}

int score[50][10];
vector<record> data;
int main(){
	//record d = record(1,2,3);
	while(true){
		data.clear();
		int t,p,r;
		memset(score,0,sizeof score);
		cin >> t >> p >> r;
		if(t==0&&p==0&&r==0)return 0;
		for(int i=0;i<t;i++)data.push_back(record(0,0,i));

		for(int i=0;i<r;i++){
			int tid,pid,time;
			string str;
			cin >> tid >> pid >> time >> str;
			tid--;
			pid--;
			if(str=="WRONG"){
				score[tid][pid]++;
			}else{
				data[tid].c++;
				data[tid].p+=time;
				data[tid].p+=score[tid][pid]*1200;
			}
		}
		sort(data.begin(),data.end(),cmp);
		for(int i=0;i<data.size();i++){
			cout << data[i].id+1 <<" "<< data[i].c<<" " << data[i].p << endl;
		}
	}
}

C++: #include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int t, p, r;
    while (true)
    {
        cin >> t >> p >> r; //???????????°???????????°?????¬???????????°
        if (t == 0)
            break;
        int seikai[t + 1] = {0}, penalty[t + 1] = {0}, gotou[t + 1][p + 1] = {0};
        for (int i = 0; i < r; i++)
        {
            int tID, pID, time;
            string s;
            cin >> tID >> pID >> time >> s;
            if (s == "CORRECT")
            {
                seikai[tID]++;
                penalty[tID] += gotou[tID][pID] * 1200 + time;
            }
            else
            {
                gotou[tID][pID]++;
            }
        }
        bool checked[t + 1] = {false};
        for (int i = 1; i <= t; i++)
        {
            int team, seikaimax = -1, pena = INF;
            for (int j = 1; j <= t; j++)
            {
                if (!checked[j])
                {
                    if (seikaimax < seikai[j])
                    {
                        seikaimax = seikai[j];
                        team = j;
                        pena = penalty[j];
                    }
                    else if (seikaimax == seikai[j])
                    {
                        if (pena > penalty[j])
                        {
                            team = j;
                            pena = penalty[j];
                        }
                    }
                }
            }
            checked[team] = true;
            cout << team << " " << seikaimax << " " << pena << endl;
        }
    }
}

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

using namespace std;

struct LOG_DATA{
  bool is;
  int wa, t;
  LOG_DATA(){ is = false; wa = 0; t = 0; }
  void correct(int t_){ is = true; t = t_ + 1200*wa; }
  void wrong(){ ++wa; }
};

struct RESULT_DATA{
  int id, ans, pn;
  RESULT_DATA(){ id = 0; ans = 0; pn = 0; }
};

bool compare(const RESULT_DATA& a, const RESULT_DATA& b){
  if(a.ans != b.ans) return (a.ans > b.ans);
  if(a.pn != b.pn) return (a.pn < b.pn);
  return (a.id < b.id);
}

int main(){
  int t, p, r;
  int t_, p_, time;
  string result;

  while(1){
    cin >> t >> p >> r;
    if(!t && !p && !r) break;

    vector< vector<LOG_DATA> > data1(t, vector<LOG_DATA>(p, LOG_DATA()));
    for(int i=0; i<r; ++i){
      cin >> t_ >> p_ >> time >> result;
      --t_; --p_;
      if(data1[t_][p_].is) continue;
      if(result == "CORRECT") data1[t_][p_].correct(time);
      else data1[t_][p_].wrong();
    }

    vector<RESULT_DATA> data2(t, RESULT_DATA());
    for(int i=0; i<t; ++i){
      data2[i].id = i+1;
      for(int j=0; j<p; ++j){
	if(!data1[i][j].is) continue;
	++data2[i].ans;
	data2[i].pn += data1[i][j].t;
      }
    }

    sort(data2.begin(), data2.end(), compare);
    for(int i=0; i<t; ++i)
      cout << data2[i].id << " " << data2[i].ans << " " << data2[i].pn << endl;
  }
  return 0;
}