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 <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;

class C{
  public:
    int num, ac, time;
    vector<int> wa;
    C(int p, int n){
      num = n;
      ac = 0;
      time = 0;
      wa = vector<int>(p, 0);
    }
    C(){}
    bool operator < (const C &c) const {
      if(ac != c.ac) return ac > c.ac;
      if(time != c.time) return time < c.time;
      return num < c.num;
    }
};

int main() {
  int T, P, R;
  while(cin >>T >>P >>R && T){
    vector<C> teams(T);
    REP(i, T) teams[i] = C(P, 1 + i);
    REP(i, R){

      int t, p, time;
      string s;
      cin >>t >>p >>time >>s;
      --t; --p;
      if(s == "CORRECT"){
        ++teams[t].ac;
        teams[t].time += 1200 * teams[t].wa[p] + time;
      } else ++teams[t].wa[p];
    }
    SORT(teams);
    REP(i, T) cout <<teams[i].num <<" " <<teams[i].ac <<" " <<teams[i].time <<endl;
  }
  return 0;
}

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

using namespace std;

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

#define all(v) v.begin(),v.end()
#define INF 1<<30
#define mp make_pair
#define pb push_back

#define fi first
#define se second

#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

typedef long long ll;

int main(){
	while(1){
		int T,P,R; cin>>T>>P>>R;
		if(T==0) break;
		vi pnt(T,0);
		vi cnt(T,0);
		vvi ws(T,vi(P,0));

		rep(i,R){
			int t,p,sec;
			string mes;
			cin>>t>>p>>sec>>mes;
			if(mes=="CORRECT"){
				cnt[t-1]++;
				pnt[t-1]+=(ws[t-1][p-1]*1200+sec);
			}
			else{
				ws[t-1][p-1]++;
			}
		}

		vi team(T);
		rep(i,T) team[i]=i;

		/*
		cout<<"-----"<<endl;
		rep(i,T){
			cout<<team[i]+1<<" "<<cnt[team[i]]<<" "<<pnt[team[i]]<<endl;
		}
		cout<<"-----"<<endl;
		*/

		rep(i,T){
			rep(j,T-1){
				int a = team[j];
				int b = team[j+1];
				if(cnt[a]<cnt[b] || (cnt[a]==cnt[b] && pnt[a]>pnt[b]) ){
					//cout<<"a: "<<a+1<<" "<<cnt[a]<<" "<<pnt[a]<<endl;
					//cout<<"b: "<<b+1<<" "<<cnt[b]<<" "<<pnt[b]<<endl;
				// || (cnt[i]==cnt[j] && pnt[i]==pnt[j] && team[i] < team[j]) ){
					swap(team[j],team[j+1]);
				}
			}
		}
		/*
		rep(i,T*T){
			int a = team[i];
			int b = team[i+1];
			if(cnt[a]==cnt[b] && pnt[a]==pnt[b] && team[a] > team[b]){
				swap(team[a],team[b]);
			}
		}
		*/
		rep(i,T){
			cout<<team[i]+1<<" "<<cnt[team[i]]<<" "<<pnt[team[i]]<<endl;
		}
	}
	return 0;
}

C++: #include <bits/stdc++.h>

#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define ALL(v) (v).begin(), (v).end()
#define INF 1e9

using namespace std;

struct team{
  int tid;
  int times;
  int correct;
  array<bool, 10> ans;
  array<int, 10> miss;
  team(int i) : tid(i), times(0), correct(0), ans({false}), miss({0}) {}
  bool operator<(const team& x)const{
    if(correct > x.correct) return true;
    if(correct < x.correct) return false;
    if(times < x.times) return true;
    if(times > x.times) return false;
    if(tid < x.tid) return true;
    return false;
  }
};

int main(){
  int t, p, r;
  vector<team> teams;
  while(cin >> t >> p >> r and t + p + r){
    REP(i, t) { teams.emplace_back(i+1); }
    REP(i, r) {
      int tid, pid, tim;
      cin >> tid >> pid >> tim;
      tid--;
      pid--;
      string res;
      cin >> res;
      if(teams[tid].ans[pid]) continue;
      if(res == "CORRECT") { teams[tid].times += teams[tid].miss[pid] * 1200 + tim; teams[tid].ans[pid] = true; teams[tid].correct++; }
      if(res == "WRONG") { teams[tid].miss[pid]++; }
    }
    sort(ALL(teams));
    REP(i, t) cout << teams[i].tid << " " << teams[i].correct << " " << teams[i].times << endl;
    teams.clear();
  }
  return 0;
}

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


struct team{

	  int  id, c, p;
	  vector<int> w;
	  team(int i, int correct, int pena, int num_pro){
			id = i; c = correct; p = pena; w = vector<int>(num_pro+1,0);
	  }
	  bool operator < (const team& tgt) const {
			if(c != tgt.c) return c < tgt.c;
			if(p != tgt.p) return p > tgt.p;
			return id > tgt.id;
	  }
	  bool operator > (const team& tgt) const {
			if(c != tgt.c) return c > tgt.c;
			if(p != tgt.p) return p > tgt.p;
			return id > tgt.id;
	  }

};

int main(){
	  
	  while(1){
			int t,p,r; cin >> t >> p >> r;
			if(!t) break;

			vector<team> teams;
			teams.push_back( team(10000,-1,1000000,10) );
			for(int i=1; i<=t; i++)
				  teams.push_back( team(i,0,0,p) );
			
			for(int i=0; i<r; i++){
				  int tid,pid,time;
				  string m;
				  cin >> tid >> pid >> time >> m;

				  if(m == "CORRECT"){
						teams[tid].c ++;
						teams[tid].p += teams[tid].w[pid] * 1200 + time;
				  }
				  else{
						teams[tid].w[pid]++;
				  }
			}
			sort(teams.begin(),teams.end());
			reverse(teams.begin(),teams.end());
			for(int i=0; i<t; i++)
				  cout << teams[i].id << " " << teams[i].c << " " << teams[i].p << endl;
				  
	  }
	  
}