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<vector>
#include<algorithm>
using namespace std;
struct kk{
int id;
int ac;
int wa;
vector<int> p;//譬ク蝠城。後↓蟇セ縺吶ｋ繝壹リ繝ォ繝?ぅ
vector<bool>acs;
int psum;
};
//
kk ans[105];
int main(){
	int T,P,R;
	while(cin>>T>>P>>R&&(T+P+R)!=0){//T繝√?繝??P蝠?R蛟九?繝ュ繧ー
	for(int i=0;i<105;i++){
	ans[i].p.resize(180);
	ans[i].acs.resize(190);
	for(int j=0;j<103;j++)ans[i].p[j]=0,ans[i].acs[j]=0;
	ans[i].id=i;
	}

	for(int i=0;i<R;i++){
	int a,b,c;//id,蝠城。景d,邨碁℃譎る俣
	string d;//繝。繝?そ繝シ繧ク
	cin>>a>>b>>c>>d;
	if(d=="WRONG"){
	ans[a].p[b]++;
	}
	else if(d=="CORRECT"){
	ans[a].ac++;
	ans[a].acs[b]=true;
	ans[a].p[b]=ans[a].p[b]*1200+c;
	}
	}
	for(int i=1;i<=T;i++){
		int sum=0;
		for(int j=0;j<=P;j++)if(ans[i].acs[j])sum+=ans[i].p[j];
		ans[i].psum=sum;
	}

	//for(int i=1;i<=T;i++)cout<<ans[i].id<<" "<<ans[i].ac<<" "<<ans[i].psum<<endl;
	for(int i=1;i<=T;i++){
		for(int j=i+1;j<=T;j++){
			if(ans[i].ac<ans[j].ac)swap(ans[i],ans[j]);//蜿ウ縺ョ縺サ縺?′蠑キ縺代ｌ縺ーswap
			else if(ans[i].ac==ans[j].ac){

				if(ans[i].psum>ans[j].psum)swap(ans[i],ans[j]);
				if(ans[i].psum==ans[j].psum&&ans[i].id>ans[j].id)swap(ans[i],ans[j]);
			}
		}
	}
	for(int i=1;i<=T;i++){
	cout<<ans[i].id<<" "<<ans[i].ac<<" "<<ans[i].psum<<endl;
	}
		for(int i=0;i<=104;i++){ans[i].p.clear();ans[i].acs.clear();ans[i].psum=0;ans[i].ac=0;ans[i].wa=0;ans[i].id=0;}
	}
		return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
//ranker
using namespace std;

#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using psi = pair<string, int>;
using D = double;

void merge (int *first1, int *last1, int *first2, int *last2){
    int size1 = last1 - first1;
    int size2 = last2 - first2;
    int *result = new int[size1+size2];
    int i = 0;
    int j = 0;
    int index = 0;
    while (true){
        if (i < size1 && (first1[i] <= first2[j] || j >= size2)){
            result[index] = first1[i];
            ++i; ++index;
        }
        if (j < size2 && (first1[i] > first2[j] || i >= size1)){
            result[index] = first2[j];
            ++j; ++index;
        }
        if (i==size1 && j==size2){
            for (i=0; i<size1; ++i) first1[i] = result[i];
            for (j=0; j<size2; ++j) first2[j] = result[j+size1];
            delete[] result;
            return;
        }
    }
}
void MergeSort (int *first, int *last){
    int size = last - first;
    if(size <= 1) return;
    MergeSort(first, first+size/2);
    MergeSort(first+size/2, last);
    merge(first, first+size/2, first+size/2, last);
}

//?????°????????????
void sort2vectors(vector<int> &av, vector<int> &bv)
{
        int n = av.size();
        vector<int> p(n), av2(n), bv2(n);
        iota(p.begin(), p.end(), 0);
        sort(p.begin(), p.end(), [&](int a, int b) { return av[a] < av[b]; });
        for (int i = 0; i < n; i++) {
                av2[i] = av[p[i]];
                bv2[i] = bv[p[i]];
        }
        av = av2;
        bv = bv2;
}


int gcd(int a, int b)
{
    int c;
    if (a < b) {
        a+=b; b=a-b; a-=b;
    }
    while (b != 0) {
        c = a % b;
        a = b;
        b = c;
    }
    return a;
}

int isPrime(int x){
  int i;
  if(x < 2) return 0;
  else if(x == 2) return 1;
  if( x%2 == 0) return 0;
  for(i = 3; i*i <= 2; i += 2){
    if(x%i == 0) return 0;
  }
  return 1;
}


const int pmax = 10000000;
bool isPrime_table[pmax];
//const???????????¨????????£?¨???§?????????

void eratos(void){
  int i, j;
  double sqrtmax=sqrt(pmax);

  REP(k, pmax) isPrime_table[k] = true; /* Initialization */

  /* Sieve process  */
  isPrime_table[0] = false;
  isPrime_table[1] = false;
          /* 0 and 1 are not prime. */
  for (i=2; i <= sqrtmax; i++){
    if (isPrime_table[i]==true){   /* i is prime. */
      for (j=i; i*j<pmax; j++){
        isPrime_table[i*j] = false; /* multiples of i are not prime. */
      }
    }
  }
}

//????????????????¨???°?????????
//abs(dx[i]+dy[j])==1??§??????
int dx[3]={-1, 0, 1};
int dy[3]={-1, 0, 1};
int W0, H0;
int  masu0[100][100]={0};
int cnt0;

int dfs(int a, int b){
  masu0[a][b] = 2;
  REP(i, 3)REP(j, 3){
    a = a+dx[i];
    b = b+dy[j];
    if(masu0[a][b]== 1 && a >= 0 && a < W0 && b >= 0 && b < H0){
    dfs(a, b);
  }
  }
  return 1;
}

//????????????????????????str.substr(i, 5)
//????????°????????? stoi, stod ??¨to_string
//?????????memset
//?????°??????????????????
//dp

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

  int T, P, R;
  while(1){
    cin >> T >> P >> R;
    if(T == 0 && P == 0 && R == 0) break;
    int tID, pID, time0;
    string message;
    int score[T] = {0};
    int prob[T][P];
    REP(i, T) REP(j, P) prob[i][j] = 0;
    int penalty[T] = {0};
    REP(i, R){
      cin >> tID >> pID >> time0 >> message;
      if(message == "CORRECT"){
        score[tID-1]++;
        penalty[tID-1] += prob[tID-1][pID-1]*1200+time0;
      }else{
        prob[tID-1][pID-1]++;
      }
    }

    vi vscore;
    vi vpenalty;
    vi vteam;
    REP(i, T){
      int tmp;
      tmp = score[i];
      vscore.push_back(tmp);
      tmp = penalty[i];
      vpenalty.push_back(tmp);
    }
    vi vvscore;
    REP(i, T){
      int tmp;
      tmp = score[i];
      vvscore.push_back(tmp);
      vteam.push_back(i);
    }
    sort2vectors(vscore, vpenalty);
    sort2vectors(vvscore, vteam);
    DEP(i, T-1){
      cout << vteam[i]+1 << " " << vscore[i] << " " << vpenalty[i] << endl;
    }
  }
  return 0;
}