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

using namespace std;

struct status{
	int correct, penalty, teamid;
	status():correct(0), penalty(0), teamid(0){}
};

bool cmpr(const status& a, const status& b){
	if(a.correct != b.correct)
		return a.correct > b.correct;
	else if(a.penalty != b.penalty)
		return a.penalty < b.penalty;
	else
		return a.teamid < b.teamid;
}

int main(){
	
	int t, p, r;
	int tried[64][16];
	
	while(cin>>t>>p>>r, (t||p||r)){
		
		vector<status> teams(t);
		memset(tried, 0, sizeof(tried));
		
		for(int i=0; i<t; ++i){
			teams[i].teamid=i+1;
		}
		
		for(int i=0; i<r; ++i){
			
			int tid, pid, time;
			string mes;
			
			cin>>tid>>pid>>time>>mes;
			tid--;
			
			if(mes == "CORRECT"){
				teams[tid].correct++;
				teams[tid].penalty+=tried[tid][pid]*1200+time;
			}
			else if(mes == "WRONG"){
				tried[tid][pid]++;
			}
		}
		
		sort(teams.begin(), teams.end(), cmpr);
		
		for(int i=0; i<t; ++i){
			cout << teams[i].teamid << " " << teams[i].correct
					<< " " << teams[i].penalty << endl;
		}
	}

	return 0;
}

C++: #include "bits/stdc++.h"
using namespace std;
struct aa {
	int id;
	int score;
	int num;
	aa() {
		id = 0;
		score = 0;
		num = 0;
	};
};
bool operator<(const aa&l, const aa&r) {
	return l.num == r.num ? l.score == r.score ? l.id<r.id : l.score<r.score : l.num >r.num;
}
int main() {
	while (1) {
		int T, P, R; cin >> T >> P >> R;
		if (!T)break;
		int miss[100][100];
		memset(miss, 0, sizeof(miss));
		int score[100][100];
		memset(score, 0, sizeof(score));
		for (int i = 0; i < R; ++i) {
			int a, b, c; cin >> a >> b >> c;
			a--; b--;
			string st; cin >> st;
			if (st == "WRONG") {
				miss[a][b]++;
			}
			else {
				score[a][b] += miss[a][b] * 1200 + c;
			}
		}
		vector<aa>scores(T);
		for (int i = 0; i < T; ++i) {
			scores[i].id = i;
			for (int j = 0; j < P; ++j) {
				scores[i].score += score[i][j];
				if (score[i][j])scores[i].num++;
			}
		}
		sort(scores.begin(), scores.end());
		for (auto s : scores) {
			cout << s.id+1 << " " << s.num << " " << s.score << endl;
		}
	}
	return 0;
}

C++: #include<iostream>
#include<tuple>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int t,p,r,tid,pid,time;
  string mess;
  cin >>t >>p>>r;
  while(t!=0){
    //           ans time id
    vector<tuple<int,int,int> > teams;
    int wrong[t][p];
    for(int i=0;i<t;i++){
      for(int j=0;j<p;j++){
        wrong[i][j]=0;
      }
      teams.push_back(make_tuple(0,0,-(i+1)));
    }
    for(int i=0;i<r;i++){
      cin >> tid>>pid>>time>>mess;
      tid--;
      pid--;
      if(mess=="CORRECT"){
        get<0>(teams[tid]) += 1;
        get<1>(teams[tid]) += wrong[tid][pid]*1200+time;
      }else{
        wrong[tid][pid]++;
      }
    }
    for(int i=0;i<t;i++){
      get<1>(teams[i])*=-1;
    }
    sort(teams.begin(),teams.end(),greater<tuple<int,int,int> >());
    for(int i=0;i<t;i++){
      int id=-get<2>(teams[i]);
      cout << id<< " "<<(get<0>(teams[i]))<< " "<<-get<1>(teams[i])<<endl;
    }
    cin >>t >>p>>r;
  }
}