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 <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

class State
{
public:
	int No,ok,pena;
	State(int No = 0,int ok = 0, int pena = 0):
	No(No),ok(ok),pena(pena){}

	bool operator < (const State &ano) const{
		if(ok > ano.ok)return true;
		else if(ok == ano.ok && pena < ano.pena)return true;
		else if(ok == ano.ok && pena == ano.pena && No < ano.No)
			return true;
			return false;
	}
};

int main()
{
	int T,P,R;

	while(cin >> T >> P >> R, T){
		int **d = new int *[T];
		State *a = new State[T];
		for(int i = 0; i < T; i++){
			d[i] = new int [P];
			a[i].No = i+1,a[i].ok = 0,a[i].pena = 0;

			for(int j = 0; j < P; j++)
				d[i][j] = 0;
		}

		int team,prog,time;
		string str;
		while(R > 0){
			R--;
			cin >> team >> prog >> time >> str;

			if(str == "WRONG")
				d[team-1][prog-1]++;
			else {
				a[team-1].pena += d[team-1][prog-1]*1200+time;	//ペナルティ
				a[team-1].ok++;	//正解数
			}
		}

		sort(a,a+T);

		for(int i = 0; i < T; i++)
			printf("%d %d\n",a[i].No, a[i].pena);

			



	}

	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>

#define INF 999999999
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define MOD(x) (x%(mod))
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

/*---------------------------------------------------*/

void judge_sort(pair<pi,int>score[],int t){
  //sort(score,score+t);reverse(score,score+t);
  rep(j,t)rep(i,t-1){
    //cout<<"DEBUG "<<score[i].first.second<<" "<<score[i+1].first.second<<endl;
    if((score[i].first.first < score[i+1].first.first)||
			(score[i].first.first == score[i+1].first.first && score[i].first.second > score[i+1].first.second)||
                        (score[i].first.first == score[i+1].first.first && score[i].first.second == score[i+1].first.second&&score[i].second > score[i+1].second)){
                               swap(score[i].first.first,score[i+1].first.first);
                               swap(score[i].first.second,score[i+1].first.second);
                               swap(score[i].second,score[i+1].second);
    }
  }
}

int main(){
  pair<pi,int>score[55];
  int wa[55][12];
  string s;
  int t,p,r,tID,pID,time;
  
  while(cin>>t>>p>>r){
    if(t==0&&p==0&&r==0)break;

    rep(i,55){
      score[i].second=i+1;
      score[i].first.first=0;
      score[i].first.second=0;
      rep(j,12){
	wa[i][j]=0;
      }
    }
    
    rep(i,r){
      cin>>tID>>pID>>time>>s;
      
      if(s=="CORRECT"&&wa[tID-1][pID]!=-1){
	score[tID-1].first.first+=1;
	//cout<<"tID: "<<tID<<" <-- "<<time+wa[tID-1][pID]*1200<<endl;
	score[tID-1].first.second+=(time+wa[tID-1][pID]*1200);
	wa[tID-1][pID]=-1;
      }else if(s=="WRONG"&&wa[tID][pID]!=-1){
	wa[tID-1][pID]++;
      }
      
    }
    judge_sort(score,t);
    
    rep(i,t)cout<<score[i].second<<" "<<score[i].first.first<<" "<<score[i].first.second<<endl;
    //cout<<endl;
  }
  return 0;
}

C++: #define _CRT_SECURE_NO_WARNINGS // #pragma warning(disable:4996)
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <functional>
#include <sstream>
#include <cmath>
#include <set>
#include <map>
#include <stack>
using namespace std; 

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define all(a) a.begin(),a.end()
#define len(x) ((int)(x).size())
#define tmax(a,b,c) max((a),max((b),(c)))
#define tmin(a,b,c) min((a),min((b),(c)))
#define debug(x) cerr << #x << " is " << x << endl;

typedef pair<int, int> Pii;
typedef map<int, int> Mii;
typedef vector<int> Vi;
typedef long long ll;
const int inf = 2e9;
const ll ll_inf = 1e17;
const int mod = 1e9 + 7;
const long double eps = 1e-10;

struct team
{
	int id;
	int pen = 0;
	int cor = 0;
	int cnt[11] = {};
	bool f[11] = {};
};

bool operator<(team& lhs, team& rhs) {
	if (lhs.cor != rhs.cor)
		return lhs.cor > rhs.cor;
	if (lhs.pen != rhs.pen)
		return lhs.pen < rhs.pen;
	return lhs.id < rhs.id;
}

int main()
{
	while (1) {
		int t, p, r;
		cin >> t >> p >> r;
		if (!t && !p && !r) break;
		team ts[51];
		rep(i,0,t) ts[i].id = i+1;
		rep(i, 0, r) {
			int a, b, c;
			string s;
			cin >> a >> b >> c >> s;
			a--; b--;
			if (ts[a].f[b]) continue;
			if (s == "CORRECT") {
				ts[a].cor++;
				ts[a].pen += 1200 * ts[a].cnt[b] + c;
			}
			else {
				ts[a].cnt[b]++;
			}
		}
		sort(ts, ts+t);
		rep(i,0,t) cout << ts[i].id << " " << ts[i].cor << " " << ts[i].pen << endl;
	}
	return 0;
}

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

using namespace std;

class St{
public:
  int td, sc, pn, ac;

  St() {}
  St(int _td, int _sc, int _pn, int _ac): td(_td), sc(_sc), pn(_pn), ac(_ac) {}

  void print(){
    cout << td << " " << ac << " " << sc << endl;
  }
};

int t, r, p;

bool comp(const St& s1, const St& s2)
{
  if(s1.ac == s2.ac){
    if(s1.sc == s2.sc) return s1.pn < s2.pn;
    return s1.sc < s2.sc;
  }

  return s1.ac > s2.ac;
}

int main()
{
  string str;
  vector<St> vec;
  int td, pd, tm;
  bool a[51][11];
  int sv[51][11];

  while(cin>>t>>r>>p && t+r+p){
    for(int i = 0; i < t; ++i) vec.push_back(St(i+1, 0, 0, 0));
    fill(&a[0][0], &a[51][0], false);
    fill(&sv[0][0], &sv[51][0], 0);

    while(p--){
      cin >> td >> pd >> tm >> str;
      if(a[td][pd]) continue;

      if(str == "CORRECT"){
	a[td][pd] = true;
	++vec[td-1].ac;
	vec[td-1].sc += (tm+1200*sv[td][pd]);
      } else {
	++sv[td][pd];
	++vec[td-1].pn;
      }
    }
    sort(vec.begin(), vec.end(), comp);

    for(int i = 0; i < vec.size(); ++i)
      vec[i].print();

    vec.clear();
  }

  return 0;
}