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 <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;




const int INF = 1000000;
const int mod = 1e9 + 7;




struct team {
	int num, ac, t;
	vi miss;
	team(int num) : num(num){
		ac = t = 0;
		miss = vi(11, 0);
	}
	team(int num, int a) : num(num){
		ac = t = 0;
		miss = vi(a + 1, 0);
	}
	bool operator < (team T) {
		if (ac != T.ac) return ac > T.ac;
		if (t != T.t) return t < T.t;
		return num < T.num;
	}
	void accept(int n, int time) {
		ac++;
		t += miss[n] * 1200 + time;
	}
	void wrong(int n) {
		miss[n]++;
	}
};

bool cmp(team t1, team t2) {
	return t1 < t2;
}

int main() {
	int t, p, r;
	while (cin >> t >> p >> r) {
		if (t == 0 && p == 0 && r == 0) break;
		vector<team> v;
		rep(i, t) v.push_back(team(i + 1, p));
		int tid, pid, time;
		string mes;
		rep(i, r) {
			cin >> tid >> pid >> time >> mes;
			if (mes == "CORRECT") v[tid - 1].accept(pid, time);
			else v[tid - 1].wrong(pid);
		}
		sort(all(v), cmp);
		rep(i, t) {
			cout << v[i].num << " " << v[i].ac << " " << v[i].t << endl;
		}
	}
}

C++: #include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
using namespace std;
const int INF = 1<<29;
const string W= "WRONG";
const string C= "CORRECT";
vector<string> split(string str,string delim){
  vector<string> items;
  size_t dlm_idx;
  if(str.npos == (dlm_idx = str.find_first_of(delim))){
    items.push_back(str.substr(0,dlm_idx));
  }
  while(str.npos != (dlm_idx = str.find_first_of(delim))){
    if(str.npos == str.find_first_not_of(delim)){
      break;
    }
    items.push_back(str.substr(0,dlm_idx));
    dlm_idx++;
    str = str.erase(0,dlm_idx);
    if(str.npos == str.find_first_of(delim) && "" != str){
      items.push_back(str);
      break;
    }
  }
  return items;
}
unsigned int sTi(const string str){
  istringstream ss(str);
  unsigned int i = 0;
  ss >> i;
  return i;
}
int main() {
  while(1){
    int T,P,R;
    cin >> T >> P >> R;
    if(T==0&&P==0&&R==0)break;
    else cout << endl;
    vector<vector<int> > teamW(T,vector<int>(P,0));
    //vector<vector<int> > teamW(T,vector<int>(P,0));
    vector<pair<int,pair<int,int> > > teamSum(T,pair<int,pair<int,int> >(0,pair<int,int>(0,0)));
    for(int i = 0;i < T;i++){
      teamSum[i].second.second = i+1;
	//		teamSum[T-tID].second.second = T-tID;
    }
    
    for(int i = 0;i < R;i++){
      int tID,pID,time;
      string mes;
      cin >> tID >> pID >> time >> mes;
      if(mes == W){
	teamW[tID-1][pID]++;
      }
      //      teamSum[T-tID].second.second = T-tID;
      if(mes == C){
	teamSum[tID-1].first++;
	teamSum[tID-1].second.first = teamSum[tID-1].second.first + time + teamW[tID-1][pID]*1200;
      }
    }
    for(int i = 0;i < T;i++){
      teamSum[i].second.first  = teamSum[i].second.first*(-1);
      teamSum[i].second.second = teamSum[i].second.second*(-1);
      
    }
    sort(teamSum.begin(),teamSum.end());//,greater<pair<int,int> >());
    for(int i = T-1;i >= 0;i--){
      cout << -1*teamSum[i].second.second  << " " << teamSum[i].first << " " << -1*teamSum[i].second.first;
      if(i != 0)cout << endl; 
    } 
    
  }
  return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<functional>
#include<stack>
#include<utility>

using namespace std;

int T[1000], P[1000], R[1000], tID[1000][500], pID[1000][500], Time[1000][500], msg[1000][500], n = 0;

int main() {
	while (cin >> T[n] >> P[n] >> R[n]) {
		if (T[n] == 0)break;
		for (int j = 0; j < R[n]; j++) {
			string messege;
			cin >> tID[n][j] >> pID[n][j] >> Time[n][j] >> messege;
			if (messege == "CORRECT")msg[n][j] = 1;
			else msg[n][j] = 0;
		}
		n++;
	}
	for (int i = 0; i < n; i++) {
		vector<pair<int, int> > AP, temp;
		AP.resize(T[i]);
		int WA[50][10]{ 0 };
		for (int j = 0; j < R[i]; j++) {
			if (msg[i][j] == 0) {
				WA[tID[i][j] - 1][pID[i][j] - 1]++;
			}
			else {
				AP[tID[i][j] - 1].first--;
				AP[tID[i][j] - 1].second += Time[i][j] + WA[tID[i][j] - 1][pID[i][j] - 1] * 1200;
			}
		}
		temp = AP;
		sort(temp.begin(), temp.end());
		int j = 0, k = 0, memo[50]{0};
		while (j < T[i]) {
			if (memo[k] > 0) {
				k++;
				continue;
			}
			if (temp[j] == AP[k]) {
				cout << k + 1 << " " << -temp[j].first << " " << temp[j].second << endl;
				j++;
				memo[k]++;
				k = 0;
			}
			else k++;
		}
	}
	return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
	int t,p,r,team,program,time;
	int solved[50],penalty[50],pp[50][10];
	string message;
	while(true){
	cin>>t>>p>>r;
	if(t==0&&p==0&&r==0)
		break;
	for(int i=0;i<t;i++){
		solved[i]=0;
		penalty[i]=0;
		for(int j=0;j<p;j++)
			pp[i][j]=0;
	}
	for(int i=0;i<r;i++){
		cin>>team>>program>>time>>message;
		if(message=="CORRECT"){
			solved[team-1]++;
			penalty[team-1]+=pp[team-1][program-1]+time;
		}
		if(message=="WRONG"){
			pp[team-1][program-1]+=1200;
		}
	}
	int junni[50];
	for(int i=0;i<t;i++)
		junni[i]=i+1;
	for(int i=0;i<t-1;i++){
		for(int j=t-1;j>i;j--){
			if(solved[j]>solved[j-1]||(solved[j]==solved[j-1]&&penalty[j]<penalty[j-1])){
				int tmp=junni[j];
				junni[j]=junni[j-1];
				junni[j-1]=tmp;
				tmp=solved[j];
				solved[j]=solved[j-1];
				solved[j-1]=tmp;
				tmp=penalty[j];
				penalty[j]=penalty[j-1];
				penalty[j-1]=tmp;
			}
		}
	}
	for(int i=0;i<t;i++)
		cout<<junni[i]<<" "<<solved[i]<<" "<<penalty[i]<<endl;
	}
	return 0;
}