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++: //
//  main.cpp
//  c
//
//  Created by 13B10694 on 2015/06/01.
//  Copyright (c) 2015????´ 13B10694. All rights reserved.
//

#include <iostream>
#include <vector>
#include<stdio.h>
#include <algorithm>
#include<string.h>
using namespace std;

int now=1;
class team{
public:    int id, pen, sol;
    int wrong[12];
    vector <int> solved;
    team(){
        memset(wrong, 0, sizeof(wrong));
        id=now++;
        pen = 0;
        sol = 0;
    }
    ~team(){
        solved.clear();
    }
    
    bool operator < (const team& b) const
    {
        return solved.size()==b.solved.size() ? pen== b.pen ? id<b.id : pen<b.pen : solved.size()>b.solved.size();
    }
};
int main() {
   // freopen("/Users/shitian/Downloads/in.txt", "r", stdin);
   // freopen("/Users/shitian/Downloads/out.txt", "w", stdout);
    int t,p,r;
    while(cin>>t>>p>>r,t){
        now=1;
        vector<team> tea(t);

        for(int i=0;i<r;i++){
            int ti, pi, tim;
            string mes;
            cin>>ti>>pi>>tim>>mes;
            ti-=1;
            if(mes=="WRONG"){
                tea[ti].wrong[pi]++;
                continue;
            }
            if(find(tea[ti].solved.begin(),tea[ti].solved.end(),pi)!=tea[ti].solved.end()){
                continue;
            }
            tea[ti].solved.push_back(pi);
            tea[ti].pen += tea[ti].wrong[pi]*1200+tim;
  
        }
        sort(tea.begin(),tea.end());
        for(int i=0;i<t;i++){
            cout<<tea[i].id<<" "<<tea[i].solved.size()<<" "<<tea[i].pen<<endl;
        }
        tea.clear();
    }
    
    return 0;
}

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

struct team{
  int ans,id,pena,p[10];
  bool operator<(const team &a)const{
    if(this->ans == a.ans){
      return this->pena < a.pena;
    }else{
      return this->ans > a.ans;
    }
  }
};

int main(){
  int t,p,r;
  while(cin>>t>>p>>r){
    if(r==0)return 0;
    int tid,tm,pid;
    string mes;
    team T[t];
    memset(T,0,sizeof(T));
    for(int i=0;i<t;i++)T[i].id=i+1;
    for(int i=0;i<r;i++){
      cin>>tid>>pid>>tm>>mes;
      tid--;pid--;
      if(mes=="CORRECT"){
	T[tid].ans++;
	T[tid].pena+=T[tid].p[pid]*1200 + tm;
      }else{
	T[tid].p[pid]++;
      }
    }
    sort(T,T+t);
    for(int i=0;i<t;i++)
      cout << T[i].id << " " << T[i].ans << " " << T[i].pena << endl;
  }
  return 0;
}

C++: #include<cstdio>
#include<algorithm>

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

using namespace std;

int main(){
	for(int n,m,q;scanf("%d%d%d",&n,&m,&q),n;){
		bool solved[50][10]={};
		int pena[50]={},wa[50][10]={};
		while(q--){
			int id1,id2,time;
			char msg[16]; scanf("%d%d%d%s",&id1,&id2,&time,msg); id1--; id2--;
			if(msg[0]=='C'){ // CORRECT
				solved[id1][id2]=true;
				pena[id1]+=1200*wa[id1][id2]+time;
			}
			else{ // WRONG
				if(solved[id1][id2]) continue;
				wa[id1][id2]++;
			}
		}

		pair<pair<int,int>,int> res[50];
		rep(i,n){
			res[i].first.first=-count(solved[i],solved[i]+m,true);
			res[i].first.second=pena[i];
			res[i].second=i;
		}
		sort(res,res+n);

		rep(i,n) printf("%d %d %d\n",res[i].second+1,-res[i].first.first,res[i].first.second);
	}

	return 0;
}

C++: #include <stdio.h>
#include <vector>
#include <algorithm>

using namespace std;

#define RMAX 500
int tid[RMAX];
int pid[RMAX];
int time[RMAX];
int ok[RMAX];

#define TMAX 50
#define PMAX 10


int pen[TMAX][PMAX];
int pent[TMAX];
int cor[TMAX];


#define TEST 0

struct Dat{
	int team;
	int cor;
	int pent;
	Dat(int team,int cor,int pent):team(team),cor(cor),pent(pent){}
	bool operator<(const Dat& ano)const{
		if(cor!=ano.cor)return cor>ano.cor;
		if(pent!=ano.pent)return pent<ano.pent;
		return team<ano.team;
	}
};


int main(void){
	int t,p,r;
	while(scanf("%d%d%d",&t,&p,&r)==3&&(t||p||r)){
		for(int i=0;i<r;i++){
			scanf("%d%d%d",tid+i,pid+i,time+i);
			int ch;
			while((ch=getchar())<=' '){}
			ok[i]=ch=='C'?1:0;
			while(getchar()>' '){}
		}
		if(TEST){
			for(int i=0;i<r;i++){
				printf("%d\n",ok[i]);
			}
		}
		for(int i=0;i<t;i++){
			pent[i]=0;
			cor[i]=0;
			for(int j=0;j<p;j++){
				pen[i][j]=0;
			}
		}
		for(int i=0;i<r;i++){
			int team=tid[i]-1;
			int prob=pid[i];
			if(ok[i]){
				cor[team]++;
				pent[team]+=pen[team][prob]+time[i];
			}else{
				pen[team][prob]+=1200;
			}
		}
		vector<Dat> vec;
		for(int i=0;i<t;i++){
			vec.push_back(Dat(i,cor[i],pent[i]));
		}
		sort(vec.begin(),vec.end());
		for(int i=0;i<vec.size();i++){
			printf("%d %d %d\n",vec[i].team+1,vec[i].cor,vec[i].pent);
		}
	}
	return 0;
}

C++: #include <iostream>
#include <string>
#include <cstdlib>

using namespace std;

typedef struct state{
	int id;
	int solved;
	int pena;
};


int compare(const void *a, const void *b){
	state *ta = (state*)a;
	state *tb = (state*)b;
	if (ta->solved != tb->solved){
		return - ta->solved + tb->solved;
	}
	else if (ta->pena != tb->pena){
		return ta->pena - tb->pena;
	}
	return ta->id - tb->id;
}

int main(void){
	int t, p, r, tid, pid, time;
	string judge;
	state st[50];
	int missed[50][10];
	while (true){
		cin >> t >> p >> r;

		if (t == 0 && p == 0 && r == 0){
			break;
		}
		for (int i = 0; i < t; i++){
			st[i].id = i + 1;
			st[i].solved = 0;
			st[i].pena = 0;
			for (int j = 0; j < p; j++){
				missed[i][j] = 0;
			}
		}


		for (int i = 0; i < r; i++){
			cin >> tid >> pid >> time;
			tid--;
			pid--;
			cin >> judge;
			if (judge == "CORRECT"){
				st[tid].pena += time + 1200 * missed[tid][pid];
				st[tid].solved++;
			}
			else{
				missed[tid][pid]++;
			}
		}

		qsort(st, t, sizeof(state), compare);

		for (int i = 0; i < t; i++){
			cout << st[i].id << " " << st[i].solved << " " << st[i].pena << endl;
		}
	}

	return 0;
}