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 <algorithm>
#include <array>
#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

struct team_t {
  array<uint32_t, 11> wrongs;
  uint64_t penalty;
  uint32_t corrects;
  uint32_t id;
  team_t() : wrongs({}), penalty(0), corrects(0), id(0) {}

  void correct(uint32_t pid, uint32_t time) {
    corrects++;
    penalty += 1200 * wrongs[pid] + time;
  }

  void wrong(uint32_t pid) { wrongs[pid]++; }

  void println() { cout << id << " " << corrects << " " << penalty << endl; }

  bool operator<(const team_t &team) const {
    return corrects == team.corrects ? penalty < team.penalty
                                     : corrects > team.corrects;
  }
};

int32_t main() {
  while (true) {
    uint32_t T, P, R;
    cin >> T >> P >> R;
    if (T == 0) break;

    vector<team_t> teams(T + 1);
    for (uint32_t i = 1; i <= T; i++) {
      teams[i].id = i;
    }

    for (uint32_t i = 0; i < R; i++) {
      uint32_t tid, pid, t;
      string msg;
      cin >> tid >> pid >> t >> msg;
      if (msg == "WRONG") {
        teams[tid].wrong(pid);
      } else if (msg == "CORRECT") {
        teams[tid].correct(pid, t);
      }
    }

    stable_sort(teams.begin() + 1, teams.begin() + 1 + T);

    for (uint32_t i = 1; i <= T; i++) {
      teams[i].println();
    }
  }

  return 0;
}

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

using namespace std;

const int INF=200000000;

int data[51][11];
int pena[51];
int ac[51];
int main(){
	int t,p,r;
	while(cin>>t>>p>>r &&t){
		for(int i=0;i<51;i++){
			for(int j=0;j<11;j++)data[i][j]=0;
		}
		fill(pena,pena+51,0);
		fill(ac,ac+51,0);

		for(int i=0;i<r;i++){
			int tID,pID,time;
			string str;
			cin>>tID>>pID>>time>>str;
			if(str=="CORRECT"){
				pena[tID]+=data[tID][pID]*1200+time;
				ac[tID]++;
			}
			else{
				data[tID][pID]++;
			}
		}
		for(int i=0;i<t;i++){
			int tmp[2]={-1,INF};
			int ans=-1;
			for(int j=1;j<=t;j++){
				if(ac[j]>tmp[0] || (ac[j]==tmp[0] && pena[j]<tmp[1])){
					tmp[0]=ac[j];
					tmp[1]=pena[j];
					ans=j;
				}
			}
			cout<<ans<<" "<<ac[ans]<<" "<<pena[ans]<<endl;
			ac[ans]=-1;pena[ans]=INF;
		}

	}
}

C++: #include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include<algorithm>
#include<complex>
#include<cstdlib>
#include<cctype>

#define REP(i,n) for(int i = 0;i < (n);i++)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cout << v[i] << ' ';cout << endl << endl;}
#define SHOW2d(v,i,j) {for(int a = 0;a < i;a++){for(int b = 0;b < j;b++)cout << v[a][b] << ' ';cout << endl;}cout << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

struct score
{
	int team,pro,wrong[11];
	ll _time;
	
	score(int t){team = t;pro = _time = 0;REP(i,11)wrong[i] = 0;}
	
	bool operator<( const score& right ) const
	{
		return pro != right.pro ? pro > right.pro :
		_time != right._time ? _time > right._time : team < right.team;
	}
};

int main()
{
	int t,p,r;
	
	while(cin >> t >> p >> r,t|p|r)
	{
		vector<score> v;
		REP(i,t)
		{
			score tmp(i);
			v.PB(tmp);
		}
		
		REP(i,r)
		{
			int ttmp,ptmp,time;string str;
			cin >> ttmp >> ptmp >> time >> str;
			if(str == "CORRECT")
			{
				v[ttmp-1].pro++;
				v[ttmp-1]._time += time + v[ttmp-1].wrong[ptmp]*1200;
			}
			else
			{
				v[ttmp-1].wrong[ptmp]++;
			}
		}
		
		stable_sort(ALL(v));
		
		REP(i,t)
		{
			cout << v[i].team+1 << ' ' << v[i].pro << ' ' << v[i]._time << endl;
		}

	}		
		
		
			
	
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int inf = 1000000;
struct D{
	int tID;
	int p[10];	//the number of incorrect problems
	int c;		//the number of correct problems
	int x;		//penalty points
};

bool rank( const D &a, const D &b ){
	return a.c == b.c ? (a.x == b.x ? a.tID < b.tID : a.x < b.x) : a.c > b.c;
}

int main(){
	int T, P, R;
	while( cin >> T >> P >> R && T ){
		vector< D > data(T);
		for( int i = 0; i < T; i++ ){
			data[i].tID = i + 1;
		}
		for( int i = 0; i < R; i++ ){
			int tID, pID, t;
			string m;
			cin >> tID >> pID >> t >> m;
			if( m == "CORRECT" ){
				if( data[tID-1].p[pID-1] != inf ){
					data[tID-1].c++;
					data[tID-1].x += t + data[tID-1].p[pID-1] * 1200;
					data[tID-1].p[pID-1] = inf;
				}
			}else{
				data[tID-1].p[pID-1]++;
			}
		}
		sort( data.begin(), data.end(), rank );
		for( int i = 0; i < T; i++ ){
			cout << data[i].tID << " " << data[i].c << " " << data[i].x << endl;
		}
	}
}

C++: #include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<stack>
#include<queue>
#include<sstream>
#include<string>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;


using namespace std;

struct Team{
  int t_num;
  int t_correct;
  int t_time;
  int t_wrong[11];
  Team(int n,int p){
    t_num=n;
    t_correct=0;
    t_time=0;
    rep(i,p) t_wrong[i]=0;
  }
};

//構造体ソート
class sort_type1{
  public:
    bool operator()(const Team& a,const Team& b){
      
      if(a.t_correct!=b.t_correct) return a.t_correct > b.t_correct;

      return a.t_time < b.t_time;
    }
};

int main(){
  
  while(1){
    int T,P,R;
    cin >> T >> P >> R;
    
    if(T==0&&P==0&&R==0) break;
    
    vector<Team> list;
    rep(i,T){
      Team tmp(i,P);
      list.push_back(tmp);
    }
    
    rep(i,R){
      int t,p,time;
      string str;
      cin >> t >> p >> time >> str;
      t--;p--;
      if(str=="WRONG"){
        list[t].t_wrong[p]++;
       // cout << "WRONG" << endl;
      }else if(str=="CORRECT"){
        
        list[t].t_time+=(1200*list[t].t_wrong[p]);
        list[t].t_time+=time;
        list[t].t_correct++;
      }
   }

    sort(list.begin(),list.end(),sort_type1());
    rep(i,list.size()){
      cout << list[i].t_num + 1 << " " << list[i].t_correct << " " <<list[i].t_time << endl;
    }
  }


}