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 <algorithm>
#include <vector>
#include <map>
using namespace std;

typedef pair<int,int> P;

struct Score{
	// problem[i] := 問題 i を解いたかどうか
	vector<bool> problem;
	// WA[i] := 問題 i のペナルティの数
	vector<int> WA;
	// submit[i] := i 番目の提出して正解した時刻
	vector<int> submit;
};


int main(){
	int t, p, r;
	while( cin >> t >> p >> r, t || p || r ){
		// data[i] := チーム i のスコア
		vector<Score> data(t);
		
		// 初期化
		vector<bool> problem_;
		vector<int> WA_;
		for(int i=0 ; i < p ; i++ ){
			problem_.push_back( false );
			WA_.push_back( 0 );
		}
		for(int i=0 ; i < t ; i++ ){
			data[i].problem = problem_;
			data[i].WA = WA_;
		}
		
		// 入力
		for(int i=0 ; i < r ; i++ ){
			int ID, pID, time;
			string message;
			cin >> ID >> pID >> time >> message;
			ID--; pID--;
			if( message == "CORRECT" ){
				data[ID].problem[pID] = true;
				data[ID].submit.push_back( time );
			}else{
				data[ID].WA[pID]++;
			}
		}
		
		// ( -solved , (time, ID) ) を保持する配列
		vector< pair<int,P> > ans;
		// 点数計算
		for(int i=0 ; i < t ; i++ ){
			// 解いた問題数 (ソートするときに解いた問題数が多い順になるように -1 をかけておく )
			int solved = -data[i].submit.size();
			
			// time の計算 (正解した問題の提出時刻の総和)
			int time=0;
			for(int j=0 ; j < data[i].submit.size() ; j++ ){
				time += data[i].submit[j];
			}
			// WA(ペナルティ) の加算
			for(int j=0 ; j < p ; j++ ){
				if( data[i].problem[j] ){
					time += data[i].WA[j] * 1200;
				}
			}
			P pp(time,i);
			ans.push_back( pair<int,P> ( solved , pp ) );
		}
		sort( ans.begin() , ans.end() );
		for(int i=0 ; i < ans.size() ; i++ ){
			int ID = (ans[i].second.second + 1); 
			int solved = -ans[i].first; // 解いた問題数に -1 をかけて元に戻すのを忘れない.
			int time = ans[i].second.first;
			cout << ID << " " << solved << " " << time << endl;
		}
	}
}

C++: #include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define RFOR(i,m,n) for(int i=m;i>=n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265

struct team{
  int c;
  int p;
  int num;
  int w[100];
};


void f(int t,int p,int r){
  struct team a[100]={};
  rep(i,t+1){
    a[i].num=i;
  }

  rep(i,r){
    int tn,qn,ti;
    string s;
    cin>>tn>>qn>>ti>>s;
    if(s[0]=='W'){
      a[tn].w[qn]++;
    }
    else{
      a[tn].c++;
      a[tn].p+=ti+(a[tn].w[qn]*1200);
    }
  }

  FOR(i,1,t+1){
    int m=i;
    FOR(j,i+1,t+1){
      if(a[m].c<a[j].c||a[m].c==a[j].c&&a[m].p>a[j].p
        || a[m].c==a[j].c&&a[m].p==a[j].p&&a[m].num>a[j].num){
        m=j;
      }
    }
    struct team b = a[m];
    a[m]=a[i];
    a[i]= b;
  }


  FOR(i,1,t+1){
    cout<<a[i].num<<' ';
    cout<<a[i].c<<' ';
    cout<<a[i].p<<endl;
  }


}


int main(){

  while(1){
    int t,p,r;
    cin>>t>>p>>r;
    if(t==0) break;
    f(t,p,r);
  }


  return 0;
}

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

struct team{
  int ans,id,p[10],pena;
  bool operator<(const team &a)const{
    if(this->ans == a.ans){
      return this->pena < a.pena;
    }else{
      return this->ans > a.ans;
    }
  }
};

int main(){
  int t,p,r;
  while(cin>>t>>p>>r){
    if(t==0)return 0;
    team T[t];
    memset(T,0,sizeof(T));
    for(int i=0;i<t;i++)T[i].id=i+1;

    int tid,tm,pid;
    string mes;
    for(int i=0;i<r;i++){
      cin>>tid>>pid>>tm>>mes;
      tid--;pid--;
      if(mes=="CORRECT" && T[tid].p[pid]>0){
	T[tid].ans++;
	T[tid].pena+=T[tid].p[pid]*1200 + tm;
	T[tid].p[pid]=-1;
      }else{
	T[tid].p[pid]++;
      }
    }
    sort(T,T+t);
    for(int i=0;i<t;i++)
      cout << T[i].id << " " << T[i].ans << " " << T[i].pena << endl;
  }
  return 0;
}

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

int main(){
    typedef struct TEAM{
        int AC;
        int WA[12];
        int PE;
        int num;
    } team;

    while(1){
        int t, p, r; cin >> t >> p >> r;
        if(t == 0) break;
        team Team[55];
        
        //?????????
        for(int i = 1; i <= t; i++){
            Team[i].num = i;
            Team[i].AC = 0;
            Team[i].PE = 0;
            for(int j = 1; j <= p; j++) Team[i].WA[j] = 0;
        }

        
        //?????°????????????
        for(int i = 0; i < r; i++){
            int tID, pID, ti; cin >> tID >> pID >> ti;
            string message; cin >> message;

            if(message[0] == 'W'){
                Team[tID].WA[pID]++;
            }else{
                Team[tID].AC++;
                Team[tID].PE += Team[tID].WA[pID] * 1200 + ti;
            }
        }

        int flag = 1;
        while(flag == 1){
            flag = 0;
            for(int i = 1; i < t; i++){
                if(Team[i].PE > Team[i + 1].PE){
                    team temp;
                    temp = Team[i];
                    Team[i] = Team[i + 1];
                    Team[i + 1] = temp;
                    flag = 1;
                    //if(Team[i].PE == Team[j].PE) cout << "nuko" << endl;
                }
            }
        }

        flag = 1;
        while(flag == 1){
            flag = 0;
            for(int i = 1; i < t; i++){
                if(Team[i].AC < Team[i + 1].AC){
                    team temp;
                    temp = Team[i];
                    Team[i] = Team[i + 1];
                    Team[i + 1] = temp;
                    flag = 1;
                    //if(Team[i].PE == Team[j].PE) cout << "nuko" << endl;
                }
            }
        }

        for(int i = 1; i <= t; i++){
            cout << Team[i].num << " " << Team[i].AC << " " << Team[i].PE << endl;
        }
    }

    
    return 0;
}