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 <deque>
#include <map>
#include <queue>
#include <sstream>

using namespace std;

typedef int teamID;

struct TeamResult
{
    int id;
    int correctCount;
    int penalty;
};

struct ICPCResult
{
    map<teamID, TeamResult> tResult;
};

struct ProblemStatus
{
    bool clear;
    int wrongCount;
};

struct TeamStatus
{
    typedef int problemID;
    map<problemID, ProblemStatus> pStatuses;
};

struct MyComp// : public binary_function<TeamResult, TeamResult, bool>
{
    bool operator()(const TeamResult& x, const TeamResult& y) const
    {
        if (x.correctCount > y.correctCount) return false;
        if (x.correctCount == y.correctCount)
        {
            if (x.penalty < y.penalty) return false;
            if (x.penalty == y.penalty) return x.id > y.id;
        }
        return true;
    }
};

int main()
{
    deque<ICPCResult> results;
    string result;
    int T, P, R;
    while (cin >> T >> P >> R)
    {
        if (T == 0 && T == 0 && R == 0) break;
        results.push_back(ICPCResult());
        ICPCResult& curICPCResult = results.back();
        map<teamID, TeamStatus> tStatuses;
        for (int log = 0; log < R; ++log)
        {
            int tID, pID, time;
            string msg;
            cin >> tID >> pID >> time >> msg;
            ProblemStatus& thisProblemStatus = tStatuses[tID].pStatuses[pID];
            if (msg == "CORRECT")
            {
                TeamResult& thisTeamResult = curICPCResult.tResult[tID];
                thisTeamResult.id = tID;
                ++thisTeamResult.correctCount;
                thisTeamResult.penalty += thisProblemStatus.wrongCount*1200 + time;
            }
            else ++thisProblemStatus.wrongCount;
        }
        
        priority_queue<TeamResult, vector<TeamResult>, MyComp> sorted;
        for (int tID = 1; tID <= T; ++tID)
        {
            TeamResult& tResult = curICPCResult.tResult[tID];
            tResult.id = tID;
            sorted.push(tResult);
        }
        
        while (sorted.size() != 0)
        {
            const TeamResult& team = sorted.top();
            stringstream ss;
            ss << team.id << " " << team.correctCount << " " << team.penalty << endl;
            result += ss.str();
            sorted.pop();
        }
    }
    cout << result;
}

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


struct A{
	int n;
	int pena;
	int id;
	bool operator<(const A &a)const{
		if(n!=a.n)return n>a.n;
		if(pena!=a.pena)return pena<a.pena;
		return id<a.id;
	}
};
int main(){
	int T,P,R;
	int p[50][10];
	A team[50];
	while(cin>>T>>P>>R,T|P|R){
		memset(p,0,sizeof(p));
		for(int i=0;i<T;i++){
			team[i].n=team[i].pena=0;
			team[i].id=i+1;
		}
		while(R--){
			int a,b,c;
			string mes;
			cin>>a>>b>>c>>mes;
			if(mes=="WRONG")p[a-1][b-1]++;
			else{
				team[a-1].n++;
				team[a-1].pena += p[a-1][b-1]*1200+c;
			}
		}
		sort(team,team+T);
		for(int i=0;i<T;i++){
			cout<<team[i].id<<' '<<team[i].n<<' '<<team[i].pena<<endl;
		}
	}
	return 0;
}

C++: #include<iostream>
#include<vector>
using namespace std;
int G[102][102];
const int INF=-2;
int main(){
	int n,m,p;
	cin>>n;
	for(int i=0;i<102;i++)fill(G[i],G[i]+102,INF);
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cin>>p;
			G[i][p]=1;
		}
	}
	return 0;
}#include<iostream>
#include<vector>
using namespace std;
int G[102][102];
const int INF=-2;
int main(){
	int n,m,p;
	cin>>n;
	for(int i=0;i<102;i++)fill(G[i],G[i]+102,INF);
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cin>>p;
			G[i][p]=1;
		}
	}
	return 0;
}

C++: #define _CRT_SECURE_NO_WARNINGS
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<utility>
#include<iomanip>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<list>
#include<set>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define repp(i,k,n) for(int i=k;i<(int)n;i++)
using namespace std;
const int dx[4] = { 0, 1, 0, -1 }, dy[4] = { 1, 0, -1, 0 };
const int dX[8] = { 0, 1, 1, 1, 0, -1, -1, -1 }, dY[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };
struct XY
{
	int x;
	int y;
};
int in()
{
	int x;
	cin >> x;
	return x;
}
/*
(char)'1' - (int)48 = (int)1;
???1111181
*/
////////////////////////////////////////////////////



int main()
{
	int t, p, r;
	while (cin >> t >> p >> r&&t&&p&&r)
	{
		vector<pair<int, int> > a;
		vector<int> missing[100];
		pair<int, int > x;
		x.first = 0;
		x.second = 0;
		rep(i,t+1)a.push_back(x);
		rep(i, t + 1)rep(l, p + 1)missing[i].push_back(0);
		rep(i, r)
		{
			int id;
			int pr;
			int time;
			char miss[50];
			cin >> id >> pr >> time >> miss;

			if (miss[0] == 'C')
			{
				a[id].first++;
				a[id].second += missing[id][pr] * 1200 + time;

			}
			else
			{
				missing[id][pr]++;
			}

		}
		a.erase(a.begin());
		int num[100];
		rep(i, 100)num[i] = i + 1;
		bool fl = true;
		while (fl)
		{
			fl = false;
			for (int i = 1; i < a.size(); i++)
			{
				if (a[i].first > a[i - 1].first)
				{
					swap(a[i], a[i - 1]);
					swap(num[i], num[i - 1]);
					fl = true;
				}
				else if (a[i].first == a[i - 1].first&&a[i].second < a[i - 1].second)
				{
					swap(a[i], a[i - 1]);
					swap(num[i], num[i - 1]);
					fl = true;
				}
				else if (a[i].first == a[i - 1].first&&a[i].second == a[i - 1].second&&num[i] < num[i - 1])
				{
					swap(a[i], a[i - 1]);
					swap(num[i], num[i - 1]);
					fl = true;
				}
			}
		}
		for (int i = 0; i < t; i++)
		{
			cout << num[i] << " " << a[i].first << " " << a[i].second << endl;

		}
	}
}