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++: // 2016-12-10
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
using namespace std;

int main() {
	int t, p, r, ti, pi, tt;
	int c[50], w[50][10], a[50];
	string m;
	while (cin >> t >> p >> r, t) {
		for (int i = 0; i < t; i++) {
			c[i] = 0;
			a[i] = 0;
			for (int j = 0; j < p; j++) {
				w[i][j] = 0;
			}
		}
		for (int i = 0; i < r; i++) {
			cin >> ti >> pi >> tt >> m;
			if (m[0] == 'C') {
				c[ti - 1]++;
				a[ti - 1] += w[ti - 1][pi - 1] * 1200 + tt;
			} else {
				w[ti - 1][pi - 1]++;
			}
		}
		vector<pair<pair<int, int>, int>> v;
		for (int i = 0; i < t; i++) {
			v.push_back(make_pair(make_pair(p - c[i], a[i]), i));
		}
		sort(begin(v), end(v));
		for (int i = 0; i < t; i++) {
			cout << v[i].second + 1 << ' ' << p - v[i].first.first << ' ' << v[i].first.second << endl;
		}
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)

int main(){
	while(1){
		int t,p,r;
		cin>>t>>p>>r;
		if(t==0&&p==0&&r==0) break;
		int qstats[50][10];
		int score[50],pn[50];
		lp(i,50){
			score[i]=0;
			pn[i]=0;
			lp(j,10){
				qstats[i][j]=0;
			}
		}
		lp(i,r){
			int a,b,c;
			string d;
			cin>>a>>b>>c>>d;
			if(d=="CORRECT"){
				score[a]++;
				pn[a]+=c+qstats[a][b]*1200;
			}
			else{
				qstats[a][b]++;
			}
		}
		tuple<int,int,int> ans[50];
		lp(i,t){
			ans[i]=make_tuple(score[i+1],pn[i+1],500-i+1);
		}
		sort(ans,ans+t);
		reverse(ans,ans+t);
		lp(i,t){
			int ans1,ans2,ans3;
			ans1=get<2>(ans[i]);
			ans2=get<0>(ans[i]);
			ans3=get<1>(ans[i]);
			cout<<ans1<<" "<<ans2<<" "<<500-ans3<<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[64];
    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){
	  if(tid < 0) continue;
	  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 <algorithm>
#include <cstdio>
#include <string>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
using namespace std;

#define REP(i, s, e) for (int i = (s); i < (e); i++)
#define REPI(i, s, e) for (int i = (s); i <= (e); i++)
#define rep(i, n) REP(i, 0, n)
#define repi(i, n) REPI(i, 0, n)
#define ALL(v) (v).begin(), (v).end()

#define dump(x) (cout << #x << " = " << x << endl)
#define dump2(x, y) (cout << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl)
#define dump3(x, y, z) (cout << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", "<< z << ")" << endl)

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

#define MAX 51

class node {
public:
	int id;
	int solve_cnt;
	int penalty;

	node(int id):id(id), solve_cnt(0), penalty(0) {
		memset(wrong_cnt, 0, sizeof(wrong_cnt));
	}

	int wrong_cnt[MAX];

	void inc_wrong(int i) { wrong_cnt[i]++; }
	void solve(int i, int time)
	{
		penalty += time + wrong_cnt[i] * 1200;
		solve_cnt++;
	}

	bool operator<(const node& r) const {
		if (solve_cnt == r.solve_cnt &&
			penalty == r.penalty)
			return id < r.id;
		else if (solve_cnt == r.solve_cnt)
			return penalty < r.penalty;
		else
			return solve_cnt > r.solve_cnt;
	}
};

int main(void)
{
	int t, p, r;
	while (cin >> t >> p >> r, t|p|r) {
		vector<node> nodes;
		rep(i, t)
			nodes.push_back(node(i));
	
		rep(i, r) {
			int tid, pid, time;
			string message;
			cin >> tid >> pid >> time >> message;
			tid--; pid--;
			if (message == "WRONG")
				nodes[tid].inc_wrong(pid);
			else
				nodes[tid].solve(pid, time);
		}
		sort(ALL(nodes));
		rep(i, nodes.size())
			printf("%d %d %d\n", nodes[i].id+1, nodes[i].solve_cnt, nodes[i].penalty);
	}
	return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cstring>
#include<cstdlib>
using namespace std;

int main(void){
   
   string s;
   int T,P,R,tID,pID,time,cor[51][501],wr[51][501],pena[51][501],corcnt[51];   

   while(cin >> T >> P >> R,T|P|R){

      memset(cor,0,sizeof(cor));
      memset(wr,0,sizeof(wr));
      memset(pena,0,sizeof(pena));
      memset(corcnt,0,sizeof(corcnt));
      
      for(int i=0;i<R;i++){
	 cin >> tID >> pID >> time >> s;
	 if(s=="CORRECT"){
	    corcnt[tID]++;
	    cor[tID][pID]++;
	    pena[tID][pID]+=wr[tID][pID]*1200+time;
	 }
	 else wr[tID][pID]++;
      }

      int pena2[51];
      memset(pena2,0,sizeof(pena2));
      for(int i=1;i<=T;i++){
	 for(int j=1;j<=P;j++){
	    pena2[i]+=pena[i][j];
	 }
      }

      int m,n,a;

      for(int i=1;i<=T;i++){
	 m=0;
	 for(int j=1;j<=T;j++){
	    m=max(corcnt[j],m);
	 }
	 n=1000000000;
	 for(int j=1;j<=T;j++){
	    if(corcnt[j]==m && pena2[j]<n){
	       a=j;
	       n=pena2[j];
	    }
	 }
	 cout << a <<" "<< corcnt[a] <<" "<< pena2[a] << endl;
	 corcnt[a]=-1;
      }
   }
   return 0;
}