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 <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>

using namespace std;

struct Info{
	Info(){
		team_id = correct_num = penalty = 0;
	}
	int team_id,correct_num,penalty;
};

void func(int T,int P, int R){
	Info info[T];
	for(int i = 0; i < T; i++)info[i].team_id = i+1;

	int pena_table[T+1][P+1];
	for(int i = 1; i <= T; i++){
		for(int k = 1; k <= P; k++)pena_table[i][k] = 0;
	}

	int tID,pID,time;
	char message[10];

	for(int loop = 0; loop < R; loop++){
		scanf("%d %d %d %s",&tID,&pID,&time,message);

		if(message[0] == 'C'){
			info[tID-1].correct_num++;
			info[tID-1].penalty += 1200*pena_table[tID][pID] + time;
		}else{
			pena_table[tID][pID]++;
		}
	}

	for(int i = 1; i <= T-1; i++){
		for(int k = T-1; k >= i; k--){
			if(info[k].correct_num > info[k-1].correct_num)swap(info[k],info[k-1]);
			else if(info[k].correct_num == info[k-1].correct_num && info[k].penalty < info[k-1].penalty)swap(info[k],info[k-1]);
			else if(info[k].correct_num == info[k-1].correct_num && info[k].penalty == info[k-1].penalty
					&&info[k].team_id < info[k-1].team_id)swap(info[k],info[k-1]);
		}
	}

	for(int i = 0; i < T; i++){
		printf("%d %d %d\n",info[i].team_id,info[i].correct_num,info[i].penalty);
	}
}

int main(){

	int T,P,R;

	while(true){
		scanf("%d %d %d",&T,&P,&R);
		if(T == 0 && P == 0&& R == 0)break;

		func(T,P,R);
	}

    return 0;
}

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() {
    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<stdio.h>
#include<algorithm>
using namespace std;
struct S
{
	int solve,time,wa[10],ID;
	S():solve(0),time(0),ID(-1){fill_n(wa,10,0);}
	bool operator <(const S&s)const
	{
		if(solve!=s.solve)
			return solve>s.solve;
		if(time!=s.time)
			return time<s.time;
		return ID<s.ID;
	}
};
int main()
{
	int T,P,R,tID,pID,time;
	char msg[64];
	while(scanf("%d%d%d",&T,&P,&R),T)
	{
		S s[50];
		for(int i=0;i<T;++i)
			s[i].ID=i+1;
		while(R--)
		{
			scanf("%d%d%d%s",&tID,&pID,&time,msg);
			--tID, --pID;
			if(msg[0]=='C')
			{
				++s[tID].solve;
				s[tID].time += time + s[tID].wa[pID]*1200;
			}
			else
				++s[tID].wa[pID];
		}
		stable_sort(s,s+T);
		for(int i=0;i<T;++i)
			printf("%d %d %d\n",s[i].ID,s[i].solve,s[i].time);
	}
	return 0;
}

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

int wa[51][11];

struct Team {
    int ac, wa, id;
};
bool operator<(const Team &t, const Team &s) {
    return (t.ac != s.ac) ? t.ac > s.ac
              : ((t.wa != s.wa) ? t.wa < s.wa
                 : t.id < s.id);
}

int main() {
    int T, P, R;
    while(cin>>T>>P>>R, T|P|R) {
        memset(wa, 0, sizeof(wa));
        vector<Team> team(T, (Team){0,0,0});
        for (int i=0; i<T; ++i) team[i].id = i+1;
        int t, p, tt;
        string m;
        for (int i=0; i<R; ++i) {
            cin>>t>>p>>tt>>m; t--, p--;
            if (m == "CORRECT") {
                team[t].ac++;
                team[t].wa += 1200 * wa[t][p] + tt;
            } else wa[t][p]++;
        }
        sort(team.begin(), team.end());
        for (int i=0; i<T; ++i)
            cout<<team[i].id<<" "<<team[i].ac<<" "<<team[i].wa<<endl;
    }
}

C++: #include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define between(a,x,b) ((a)<=(x)&&(x)<=(b))
using namespace std;
typedef pair<int, pair<int, int> > tpair;


bool cmp(const tpair &a, const tpair &b){
  if(a.second.first != b.second.first) return a.second.first > b.second.first;
  else if(a.second.second != b.second.second) return a.second.second < b.second.second;
  else return a.first < b.first;
}


int main(){
  int T, P, R;
  while(scanf("%d%d%d", &T, &P, &R) && (T||P||R)){
    //    vector<pair<int, pair<int, int> > > t(T); // team ac p
    vector<tpair> t(T);
    int fail[11][11] = {};
    int tid, pid, time;
    char message[64];
    rep(i, T) t[i] = make_pair(i+1, make_pair(0, 0));
    rep(i, R){
      scanf("%d%d%d", &tid, &pid, &time);
      tid--;
      fprintf(stderr, "%d\n", tid);
      scanf("%s", message);
      if(message[0] == 'C'){
	  t[tid].second.first += 1;
	  t[tid].second.second += fail[tid][pid] * 1200 + time;
	  fail[tid][pid] = -1;
      }else  fail[tid][pid]++;
    }
    sort(t.begin(), t.end(), cmp);
    rep(i, T) printf("%d %d %d\n", t[i].first, t[i].second.first, t[i].second.second);
  }
  return 0;
}