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<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define MP make_pair
#define PB push_back
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP1(i,n) for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n) for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


int main()
{
	int t,p,r;
	while((cin >> t >> p >> r )&&t && p && r){
	
		int wrong[10][50] = {0};
		int tID,pID,time;
		int ansID[50];
		string msg;
		int memo[50] = {0};
		int cnt[50] = {0};

		for(int j=0;j<t;j++){
			ansID[j] = j+1;	
		}


		for(int i=0;i<r;i++){
			cin >> tID >> pID >> time >> msg;
			if(msg == "WRONG"){
				wrong[pID-1][tID-1]++;
			}else if(msg == "CORRECT"){
				memo[tID-1] += wrong[pID-1][tID-1] * 1200 + time;
				cnt[tID-1]++;
       		 	}
		}

		for(int i=0;i<t;i++){
			for(int j=i+1;j<t;j++){
				if(cnt[i] < cnt[j]){
					swap(ansID[i],ansID[j]);
					swap(cnt[i],cnt[j]);
					swap(memo[i],memo[j]);
				}
				else if(cnt[i] == cnt[j]){
					if(memo[i] > memo[j]){
						swap(ansID[i],ansID[j]);
						swap(cnt[i],cnt[j]);
						swap(memo[i],memo[j]);
					}else if(memo[i] == memo[j] && ansID[i] > ansID[j]){
						swap(ansID[i],ansID[j]);
						swap(cnt[i],cnt[j]);
						swap(memo[i],memo[j]);
					}
				}
			}
		}
		for(int i=0;i<t;i++){
			cout << ansID[i] << " " << cnt[i] << " " << memo[i] << endl;
		}
	}
	return 0;
}

C++: #include <cstdio>
#include <cassert>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <array>

using namespace std;

#define all(c) begin(c), end(c)
#define dump(c) cerr << "> " << #c << " = " << (c) << endl
#define REP(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

const int INF = 1001001001;
const double EPS = 1e-10;


template<typename T1,typename T2>
ostream& operator<<(ostream& os, const pair<T1,T2>& p){
  return os << '(' << p.first << ',' << p.second << ')';
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& a){
  os << '[';
  rep(i,a.size()) os << (i ? " " : "") << a[i];
  return os << ']';
}

int main() {
  for(int T, P, R; cin >> T >> P >> R, (T | P | R) != 0; ) {
    int ac[51][51] = {}, wa[51][51] = {};
    int nums[51] = {}, times[51] = {};
    rep(i, R) {
      int tid, pid, time;
      string mes;
      cin >> tid >> pid >> time >> mes;
      tid--;
      pid--;
      if(ac[tid][pid]) continue;
      if(mes == "CORRECT") {
        nums[tid]++;
        times[tid] += wa[tid][pid] * 1200 + time;
        ac[tid][pid] = 1;
      }
      else {
        wa[tid][pid]++;
      }
    }

    set<tuple<int, int, int>> sta;
    rep(i, T) {
      sta.insert(make_tuple(-nums[i], times[i], i));
    }

    for(auto i : sta) {
      cout << get<2>(i) + 1 << ' ' << -get<0>(i) << ' ' << get<1>(i) << endl;
    }
  }

  
  
  return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <algorithm>
#include <array>
#include <vector>
#include <tuple>

using namespace std;

bool compare( tuple<int, int, int> t1, tuple<int, int, int> t2 ) {
  if ( get<0>( t1 ) != get<0>( t2 ) ) {
    return get<0>( t1 ) > get<0>( t2 );
  } else if ( get<1>( t1 ) != get<1>( t2 ) ) {
    return get<1>( t1 ) < get<1>( t2 );
  } else {
    return get<2>( t1 ) < get<2>( t2 );
  }
}

int main() {
  while( true ) {
    int t, p, r;
    cin >> t >> p >> r;
    if ( t == 0 and p == 0 and r == 0 ) break;

    vector<int> pen( t + 1 );
    vector<int> cor( t + 1 );
    vector<vector<int>> wrong( t + 1, vector<int>( p + 1 ) );
    fill( pen.begin(), pen.end(), 0 );
    fill( cor.begin(), cor.end(), 0 );
    for ( auto ar : wrong ) {
      fill( ar.begin(), ar.end(), 0 );
    }
    
    for ( int i = 0; i < r; i++ ) {
      int tid, pid, time;
      string m;
      cin >> tid >> pid >> time >> m;
      if ( m == "WRONG" ) {
	wrong[ tid ][ pid ]++;
      } else {
	pen[ tid ] += 1200 * wrong[ tid ][ pid ] + time;
	cor[ tid ]++;
      }
    }
    vector<tuple<int, int, int>> ans( t );
    for ( int i = 1; i <= t; i++ ) {
      ans[ i - 1 ] = make_tuple( cor[ i ], pen[ i ], i );
    }
    sort( ans.begin(), ans.end(), compare );
    
    for ( auto t : ans ) {
      cout << get<2>( t ) << " " << get<0>( t ) << " " << get<1>( t ) << endl;
    }
  }
}

C++: #include <map>
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;
char M[9];
int main(){
	int T,P,R,t,p,s,m,i;
	for(;scanf("%d%d%d",&T,&P,&R),R;){
		map<int,map<int,int> >z;
		for(i=0;i<R;i++){
			scanf("%d%d%d%s",&t,&p,&s,M);
			if(*M=='W')z[t][p]-=1;
			else z[t][p]=s-z[t][p]*1200;
		}
		vector<pair<int,pair<int,int> > >v;
		for(i=1;i<=T;i++){
			for(p=s=0,R=1;R<=P;R++)
				if(z[i][R]>0)p++,s+=z[i][R];
			v.push_back(make_pair(99-p,make_pair(s,i)));
		}
		sort(v.begin(),v.end());
		for(i=0;i<T;i++)
			printf("%d %d %d\n",v[i].second.second,99-v[i].first,v[i].second.first);
	}
}