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<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstring>
#include<cstdio>
#include<cmath>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define onen(i,n) for(int i=1;i<n+1;i++)

const int MAXT = 51, MAXP = 11, MAXR = 500,MAXTIME = 10800;

int tid,pid,atime;
int t,p,r;
string message ;
int ac[MAXT], wa[MAXT][MAXP], pena[MAXT];
bool used[MAXT];
typedef pair<int, int> pp;

int main()
{
    while(cin >> t >> p >> r && t)
    {
        memset(ac, 0, sizeof(ac));
        memset(wa, 0, sizeof(wa));
        memset(used, false , sizeof(used));
        memset(pena, 0, sizeof(pena));
        
        REP(r)
        {
            cin >> tid >> pid >> atime >> message;
            if(message == "WRONG")
                wa[tid][pid]++;

            else
            {
                ac[tid]++;
                pena[tid] += (wa[tid][pid] * 1200 + atime);
            }
        }
        rep(j,t)
        {
            int topacc = -1, topp = 100000,top = 0;
            
            onen(i,t)//取り出すことをt回繰り返す
            {
                if(!used[i])
                {
                    if(topacc < ac[i] || (topacc == ac[i] && topp > pena[i]))
                    {
                        top = i;
                        topacc = ac[i];
                        topp = pena[i];
                    }
                }
            }
            used[top] = true;
            cout << top << " " << topacc << " " << topp << endl;
        }
    }

    return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cctype>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <memory>
#include <functional>
#include <set>
#include <iomanip>

using namespace std;

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < (int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define INF 1<<25
#define pb push_back
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
typedef long long ll;

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

#define MAX 1500

int main()
{
    int t,p,r;
    while(cin >>t >> p >> r,t,p,r){
        vector<int>tID;
        vector<int>pID;
        vector<int>time;
        vector<string>com;
        
        for(int i=0;i<r;i++){
            int a,b,c;
            string d;
            cin >> a >> b >> c >> d;
            tID.pb(a);
            pID.pb(b);
            time.pb(c);
            com.pb(d);
        }
        for(int i=0;i<t;i++){
            for(int j=i+1;j<t;j++){
                if(pID[i] > pID[j]){
                    swap(pID[i],pID[j]);
                    swap(tID[i],tID[j]);
                    swap(time[i],time[j]);
                    swap(com[i],com[j]);
                }
                
            }
        }
        /*
        for(int i=0;i<r;i++){
            cout << "tID:" <<tID[i] << " pID:" << pID[i] << " time:" << time[i] << " judge:" << com[i] <<  endl;
        }
         
         */
        vector<vector<int> > ans;
        vi temp;
        for(int i=0;i<t;i++){
            temp.pb(i+1);
            for(int j=1;j<4;j++){
                temp.pb(0);
            }
            ans.pb(temp);
            temp.clear();
        }
        
        for(int i=0;i<r;i++){
            if(com[i] == "CORRECT"){
                ans[tID[i]-1][1]++;
                ans[tID[i]-1][2] += (ans[tID[i]-1][3] * 1200 + time[i]);
                ans[tID[i]-1][3] = 0;

            }else{
                ans[tID[i]-1][3]++;
            }
            
        }
        for(int i=0;i<t;i++){
            for(int j=i+1;j<t;j++){
                if(ans[i][1] < ans[j][1]){
                    swap(ans[i][0],ans[j][0]);
                    swap(ans[i][1],ans[j][1]);
                    swap(ans[i][2],ans[j][2]);
                    swap(ans[i][3],ans[j][3]);
                }
                
                if(ans[i][1] == ans[j][1] && ans[i][2] > ans[j][2]){
                    swap(ans[i][0],ans[j][0]);
                    swap(ans[i][1],ans[j][1]);
                    swap(ans[i][2],ans[j][2]);
                    swap(ans[i][3],ans[j][3]);
                }
                
                if(ans[i][1] == ans[j][1] && ans[i][2] == ans[j][2] && ans[i][0] > ans[j][0]){
                    swap(ans[i][0],ans[j][0]);
                    swap(ans[i][1],ans[j][1]);
                    swap(ans[i][2],ans[j][2]);
                    swap(ans[i][3],ans[j][3]);
                }
            }
        }

        
        for(int i=0;i < t;i++){
               cout << ans[i][0] << " " << ans[i][1] <<" " << ans[i][2] << endl;
        }
    }
    return 0;
}