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>
#define N 500
using namespace std;
struct info {
  int tid[N];
  int pid[N];
  int time[N];
  string message[N];
};
int main(){
  struct info data;
  int t,p,r,i,j,tcorrect[51][11],tp[51],twrong[51][11],tcsum[51],tnum[51];
  while(1){
    cin >> t >> p >> r;
    if(t==0&&p==0&&r==0) break;
    for(i=0;i<r;i++){
      cin >> data.tid[i] >> data.pid[i] >> data.time[i] >> data.message[i];
    }
    for(i=1;i<=t;i++){
      for(j=1;j<=p;j++){
	tcorrect[i][j]=twrong[i][j]=0;
      }
      	tp[i]=0;
    }
    for(i=0;i<r;i++){
      if(data.message[i]=="CORRECT"){
	tcorrect[data.tid[i]][data.pid[i]]++;
	tp[data.tid[i]]=tp[data.tid[i]]+twrong[data.tid[i]][data.pid[i]]*1200+data.time[i];
      }
      else if(data.message[i]=="WRONG"){
	twrong[data.tid[i]][data.pid[i]]++;
      }
    }
    for(i=1;i<=t;i++){
      tcsum[i]=0;
      for(j=1;j<=p;j++){
	tcsum[i]+=tcorrect[i][j];
      }
      tnum[i]=i;
    }
    for(i=1;i<=t;i++){
      for(j=2;j<=t;j++){
	if(tnum[j]<tnum[j-1]){
	  swap(tp[j],tp[j-1]);
	  swap(tcsum[j],tcsum[j-1]);
	  swap(tnum[j],tnum[j-1]);
	}
      }
    }
    for(i=1;i<=t;i++){
      for(j=2;j<=t;j++){
	if(tp[j]<tp[j-1]){
	  swap(tp[j],tp[j-1]);
	  swap(tcsum[j],tcsum[j-1]);
	  swap(tnum[j],tnum[j-1]);
	}
      }
    }
    for(i=1;i<=t;i++){
      for(j=2;j<=t;j++){
	if(tcsum[j]>tcsum[j-1]){
	  swap(tp[j],tp[j-1]);
	  swap(tcsum[j],tcsum[j-1]);
	  swap(tnum[j],tnum[j-1]);
	}
      }
    }
    for(i=1;i<=t;i++){
      cout << tnum[i] << ' ' << tcsum[i] << ' ' << tp[i] << endl;
    }
  }
  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

typedef pair<int, int> Pii;

int main() {
  int T, P, R;
  while ( cin >> T >> P >> R, T ) {
    vector<int> cnt(T, 0);
    vector<vector<int> > solved(T, vector<int>(P, 0));    
    vector<int> times(T, 0);    
    vector<vector<int> > pena(T, vector<int>(P, 0));    
    while ( R-- ) {
      int m, t, p;
      string j;
      cin >> t >> p >> m;
      cin >> j;
      t--; p--;
      if ( j == "CORRECT" ) {
	if ( solved[t][p] ) continue;
	solved[t][p] = 1;
	times[t] += m;
	times[t] += pena[t][p]*1200;	
	cnt[t]++;	
      } else if ( !solved[t][p] ) {
	pena[t][p]++;
      }
    }

    vector<Pii> ps[P+1];    
    for ( int i = 0; i < T; i++ ) {
      ps[cnt[i]].push_back(Pii(times[i], i));      
    }

    for ( int i = P; i >= 0; i-- ) {
      if ( !ps[i].size() ) continue;
      sort(ps[i].begin(), ps[i].end());
      for ( int j = 0; j < (int)ps[i].size(); j++ ) {
	cout << ps[i][j].second+1 << " " << i << " " << ps[i][j].first << endl;	
      }
    }
      
  }

  return 0;
}

C++: #include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;
int wro[100][100];
// int b[100][100];
void mainmain(){
	int T,P,R;
	while(cin>>T>>P>>R,T||P||R){
		vector<pii> res(T);
		vector<pair<pii,int> > ans;
		rep(i,T){
			res[i]=mkp(0,0);
		}
		rep(i,100){
			rep(j,100){
				wro[i][j]=0;
				// b[i][j]=0;
			}
		}
		rep(i,R){
			int a,b,c;
			string s;
			cin>>a>>b>>c>>s;
			if(s=="WRONG"){
				wro[a-1][b-1]++;
			}
			else{
				res[a-1].F++;
				res[a-1].S+=1200*wro[a-1][b-1]+c;
			}
		}
		rep(i,T){
			ans.PB(mkp(mkp(-res[i].F,res[i].S),i));
		}
		sort(ALL(ans));
		rep(i,T){
			cout<<ans[i].S+1<<" "<<-ans[i].F.F<<" "<<ans[i].F.S<<endl;
		}
	}
}



}
main() try{
    mainmain();
}
catch(...){
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int inf = 1000000;
struct D{
	int tID;
	int p[10];	//the number of incorrect problems
	int c;		//the number of correct problems
	int x;		//penalty points
};

bool rank( const D &a, const D &b ){
	if( a.c == b.c ){
		return a.x == b.x ? a.tID < b.tID : a.x < b.x;
	}else{
		return a.c < b.c;
	}
}

int main(){
	int T, P, R;
	while( cin >> T >> P >> R && T ){
		vector< D > data(T);
		for( int i = 0; i < T; i++ ){
			data[i].tID = i + 1;
		}
		for( int i = 0; i < R; i++ ){
			int tID, pID, t;
			string m;
			cin >> tID >> pID >> t >> m;
			if( m == "CORRECT" ){
				if( data[tID-1].p[pID-1] != inf ){
					data[tID-1].c++;
					data[tID-1].x += t + data[tID-1].p[pID-1] * 1200;
					data[tID-1].p[pID-1] = inf;
				}
			}else{
				data[tID-1].p[pID-1]++;
			}
		}
		sort( data.begin(), data.end(), rank );
		for( int i = 0; i < T; i++ ){
			cout << data[i].tID << " " << data[i].c << " " << data[i].x << endl;
		}
	}
}