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 <string>
#include <algorithm>

using namespace std;

class team{
public:
	int time;
	int ac;
	vector<int> wa;
	int pe;
	int id;

	void print() const{
		cout<<id<<" "<<ac<<" "<<pe<<endl;
	}

};

bool operator<(const team& t1 , const team& t2){
	if(t1.ac != t2.ac) return t1.ac>t2.ac;
	if(t1.pe != t2.pe) return t1.pe<t2.pe;
	else		   return t1.id<t2.id;
};

int main()
{

	int t,p,r;
	while(cin>>t>>p>>r,t){
		vector<team> T(t);
		for(int i=0;i<t;i++){
			T[i].wa=vector<int>(p,0);
			T[i].id=i+1;
		}

		for(int i=0;i<r;i++){
			int tID,pID,time;
			string me;

			cin>>tID>>pID>>time>>me;
			tID--; pID--;

			if(me=="CORRECT"){
				T[tID].ac++;
				T[tID].pe+=(T[tID].wa[pID]*1200)+time;
			}else{
				T[tID].wa[pID]++;
			}

		}

		sort(T.begin(),T.end());
		for(int i=0;i<t;i++) T[i].print();

	}

	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
struct S{
  int id,a=0,p=0,w[10]={};
  bool operator<(const S&o)const{
    return a==o.a?p==o.p?id<o.id:p<o.p:a>o.a;
  }
};
int t,p,r,i,a,b,c,w[51][11];
string s;
main(){
  while(cin>>t>>p>>r,t){
    S z[t];
    for(i=0;i<t;++i)z[i].id=i+1;
    for(i=0;i<r;++i){
      cin>>a>>b>>c>>s;
      if(s=="CORRECT")z[--a].a++,z[a].p+=z[a].w[b]*1200+c;
      else z[--a].w[b]++;
    }
    sort(z,z+t);
    for(i=0;i<t;++i)cout<<z[i].id<<' '<<z[i].a<<' '<<z[i].p<<endl;
  }
}

C++: #include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
  int T, P, R, tid, pid, t;
  string m;
  while (cin >> T >> P >> R, T) {
    vector< vector<int> > V(T, vector<int>(3, 0));
    vector< vector<int> > Problem(T, vector<int>(P, 0));
    for (int i = 0; i < T; ++i) V[i][2] = i+1;
    for (int i = 0; i < R; ++i) {
      cin >> tid >> pid >> t >> m;
      --tid;
      --pid;
      if (Problem[tid][pid] != 1) {
	if (m == "CORRECT") {
	  V[tid][1] += -Problem[tid][pid]*1200 + t;
	  Problem[tid][pid] = 1;
	  --V[tid][0];
	} else {
	  --Problem[tid][pid];
	}
      }
    }
    sort(V.begin(), V.end());
    for (int i = 0; i < T; ++i) {
      cout << V[i][2] << " " << -V[i][0] << " " << V[i][1] << endl;
    }
  }
  return 0;
}

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;

struct hoge{
  bool operator()(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[16];
    rep(i, T) t[i].first = i+1;     
    rep(i, R){
      scanf("%d%d%d%s", &tid, &pid, &time, message); tid--; pid--;
      if(message[0] == 'C'){
	if(fail[tid][pid] != -1){
	//  t[tid].second.first++;
	  t[tid].second.second += 1 //fail[tid][pid] * 1200 + time;
	  fail[tid][pid] = -1; 
	}
      }else if(message[0] == 'W'){
	if(fail[tid][pid] != -1)
	  fail[tid][pid]++;
      }
    } 
    sort(t.begin(), t.end(), hoge());
    rep(i, T) printf("%d %d %d\n", t[i].first, t[i].second.first, t[i].second.second);
  }
  return 0;
}

C++: #include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2400&lang=jp>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */
int T,P,R;
struct Team{
    int id;
    int correct;
    int penalty;
    vector<int> accept;
    vector<int> wrong;
    Team(){};
    Team(int id,int P):id(id),accept(P),wrong(P),correct(0),penalty(0){}
    void AC(int P,int time){
        if(accept[P]) return;
        accept[P] = 1;
        penalty += wrong[P]*1200 + time;
        correct++;
        return;
    }
    void WA(int P){
        wrong[P]++;
    }
    bool operator < (const Team& o)const {
        return correct!=o.correct?correct>o.correct:penalty!=o.penalty?penalty<o.penalty:id<o.id;
    }
};
void solve(){
    vector<Team> info(T);
    for(int i = 0; i < T;i++) info[i] = Team(i,P);
    for(int i = 0; i < R;i++){
        int tid,pid,time; string msg;
        cin >> tid >> pid >> time >> msg;
        tid--; pid--;
        if(msg == "CORRECT"){
            info[tid].AC(pid,time);
        }else{
            info[tid].WA(pid);
        }
    }
    sort(info.begin(),info.end());
    for(Team& team:info){
        cout << team.id+1 << " " << team.correct << " " << team.penalty << endl;
    }
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    while(cin >> T >> P >> R,T){
        solve();
    }
    return 0;
}