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;
#define MAX 20

struct data{
  int id,cnt,sum;
  int p[MAX];
  void init(int x){
    id=x;
    cnt=sum=0;
    for(int i=0;i<MAX;i++)p[i]=0;
  }
  bool operator < (const data &p)const{
    if(cnt!=p.cnt)return cnt < p.cnt;
    if(sum!=p.sum)return sum > p.sum;
    return id > p.id;
  }
};

int T,P,R;
data t[100];

int main(){
  while(1){
    cin>>T>>P>>R;
    if(T==0&&P==0&&R==0)break;
    for(int i=0;i<T;i++)t[i].init(i+1);
    for(int i=0;i<R;i++){
      int a,b,c;
      string str;
      cin>>a>>b>>c>>str;
      a--,b--;
      if(str=="WRONG"){
	t[a].p[b]++;
      }else{
	t[a].cnt++;
	t[a].sum+=(t[a].p[b]*1200+c);
      }
    }

    sort(t,t+T);
    reverse(t,t+T);
    for(int i=0;i<T;i++){
      cout<<t[i].id<<' '<<t[i].cnt<<' '<<t[i].sum<<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 += 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;
int main(){
	int t,p,r;
	while(cin >> t >> p >> r,t){
		int tid,pid,time;
		string message;
		vector <pair <int,pair<int,int> >  >pen(t);
		for(int i=0;i<t;i++)
			pen[i].second.second=i+1;
		int wor[t][p];
		int done[t][p];
		for(int i=0;i<t;i++)
			for(int j=0;j<p;j++){
				wor[i][j]=0;
				done[i][j]=0;
			}
		for(int i=0;i<r;i++){
			cin >> tid >> pid >> time >> message;
			tid--; pid--;
			if(done[tid][pid]==1);
			else{
				if(message[0]=='W')
					wor[tid][pid]++;
				else{
					pen[tid].second.first+=wor[tid][pid]*1200+time;
					pen[tid].first++;
					done[tid][pid]=1;
				}
			}
		}
		sort(pen.begin(),pen.end());
		for(int i=0;i<t-1;i++){
			for(int j=t-1;j>i;j--){
				if(pen[i].first<pen[j].first){
					swap(pen[i].first,pen[j].first);
					swap(pen[i].second.first,pen[j].second.first);
					swap(pen[i].second.second,pen[j].second.second);
				}
			}
		}
		for(int i=0;i<t-1;i++){
			for(int j=t-1;j>i;j--){
				if(pen[i].second.first==pen[j].second.first&&pen[i].second.second>pen[j].second.second){
					swap(pen[i].first,pen[j].first);
					swap(pen[i].second.first,pen[j].second.first);
					swap(pen[i].second.second,pen[j].second.second);
				}
			}
		}
		for(int i=0;i<t;i++){
			cout << pen[i].second.second << " " << pen[i].first << " " << pen[i].second.first << endl;
		}
	}
}

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;

class Team{
public:
  int id, solved, penalty;
  Team(){}
  Team(int id, int solved, int penalty) : id(id), solved(solved), penalty(penalty) {}
  bool operator < (const Team& s) const {
    if(solved == s.solved){
      if(penalty == s.penalty) return id < s.id;
      return penalty < s.penalty;
    }
    return solved > s.solved;
  }
};

int T, P, R;
bool solved[50][10];
int cnt[50][10];
Team teams[50];

main(){
  while(cin >> T >> P >> R && (T|P|R)){
    fill(solved[0], solved[50], false);
    fill(cnt[0], cnt[50], 0);
    for(int i=0;i<T;i++) teams[i] = Team(i, 0, 0);
    for(int i=0;i<R;i++){
      int id, pid, time;
      string message;
      cin >> id >> pid >> time >> message;
      id--; pid--;
      if(message == "CORRECT" && !solved[id][pid]){
        solved[id][pid] = true;
        teams[id].solved++;
        teams[id].penalty += time + 1200 * cnt[id][pid];
      }else cnt[id][pid]++;
    }
    sort(teams, teams+T);
    for(int i=0;i<T;i++) cout << teams[i].id+1 << ' ' << teams[i].solved << ' ' << teams[i].penalty << endl;
  }
}

C++: #include <iostream>
#include <iomanip>
#include <sstream>
#include <stdio.h>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
#include <utility>
#include <string>
#include <ctype.h>
#include <cstring>
#include <cstdio>
#include <sstream>
#include <functional>

using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ll long long
#define SORT(v) sort((v).begin(),(v).end())
//#define scanf scanf_s

struct team{ int ac, pe, t; };

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

int main()
{
	int t, p, r;
	int rec[55][11][2];
	while (cin >> t >> p >> r)
	{
		if (t == 0 && p == 0 && r == 0) break;
		memset(rec, 0, sizeof(rec));
		int a, b, c;
		string d;
		REP(i, r)
		{
			cin >> a >> b >> c >> d;
			if (d == "CORRECT") rec[a][b][1] += rec[a][b][0] + c;
			else rec[a][b][0] += 1200;
		}
		vector<team> v;
		FOR(i, 1, t + 1)
		{
			int ac = 0;
			int pe = 0;
			FOR(j, 1, p + 1)
			{
				if (rec[i][j][1] != 0)
				{
					ac++;
					pe += rec[i][j][1];
				}
			}
			team tmp = { ac, pe, i };
			v.push_back(tmp);
		}
		sort(v.begin(), v.end(), comp);
		REP(i, v.size())
		{
			cout << v[i].t << " " << v[i].ac << " " << v[i].pe << endl;
		}
	}
	return 0;
}