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 <cstdio>
#include <cmath>
#include <math.h>
#include <string>
#include <string.h>
#include <stack>
#include <queue>
#include <vector>
#include <utility>
#include <set>
#include <map>
#include <stdlib.h>

using namespace std;


#define ld long double
#define EPS 0.0000000001
#define INF 10000000000LL
#define rep(i,n) for(i=0;i<n;i++)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int i,j;

int main(void) {

  while(1){
    int t,p,r;
    cin>>t>>p>>r;
    if(t==0 && p==0 && r==0)break;
    int i;
    pair<pll,ll> team[50]; //solved_num, time, team_num                         
    int v[50][10]={};//team_num, problem_num, wrong_num                         
    int time,tnum,pnum,j;
    string str;
    rep(i,t)
      team[i].second=-i-1;//reverse                                             
    rep(i,r){
      cin>>tnum>>pnum>>time>>str;
      tnum--;
      pnum--;
     if(str=="WRONG"){//WA                                                     
        v[tnum][pnum]++;
      }else{//AC                                                                
        team[tnum].first.first++;
        team[tnum].first.second-=time+v[tnum][pnum]*1200;//reverse              
      }
    }
    rep(i,t)
      if(team[i].first.second==0)team[i].first.second=-1000000000000LL;

    sort(team,team+t);
    for(i=t-1;i>=0;i--){
      cout<<-team[i].second<<" ";
      cout<<team[i].first.first<<" ";
      if(team[i].first.second<-100000000000)
        cout<<"0"<<endl;
      else
        cout<<-team[i].first.second<<endl;
    }
  }
  return 0;
}

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

#define CH(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)

using namespace std;

int T,P,R,tID,pID,tim;
string message;
int solv[55],pen[55], wap[55][505];

int main() {
  while(1){
    cin>>T>>P>>R;
    if(T==0&&P==0&&R==0) break;
    vector< pair<pair<int,int>,int> > v(T); //score,pen,tid
    REP(i,0,T){
      v[i].first.first = v[i].first.second = 0;
      v[i].second = i;
      REP(j,0,P) wap[i][j]=0;
    }
    REP(i,0,R){
      cin>>tID>>pID>>tim>>message;
      if(message=="CORRECT"){
        v[tID-1].first.first++;
        v[tID-1].first.second += wap[tID-1][pID-1]*1200+tim;
      }else{
        wap[tID-1][pID-1]++;
      }
    }
    sort(v.begin(),v.end());
    for(int score=P; 0<=score; score--){
      REP(i,0,v.size()){
        if(v[i].first.first==score) cout<<v[i].second+1<<" "<<v[i].first.first<<" "<<v[i].first.second<<endl;
      }
    }
  }

  return 0;
}

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

using namespace std;

#define MAX_P 11

struct Team {
	int tid;
	int penalty;
	int correct;
	int wrong[MAX_P];
	Team() {
		correct = 0;
		penalty = 0;
		for (int i = 0; i < MAX_P; i++) wrong[i] = 0;
	}
	bool operator<(const Team &o) const {
		return correct == o.correct ? 
					penalty == o.penalty ?
						tid < o.tid : penalty < o.penalty
				  : correct > o.correct;
	}
};

int main() {
	int T, P, R;
	while (cin >> T >> P >> R) {
		if (T == 0 && P == 0 && R == 0) break;
		Team team[T+1];
		for (int i = 1; i <= T; i++) team[i].tid = i;
		for (int i = 0; i < R; i++) {
			int tid, pid, time; string res;
			cin >> tid >> pid >> time >> res;
			if (res == "CORRECT") {
				team[tid].correct++;
				team[tid].penalty += time;
				team[tid].penalty += team[tid].wrong[pid] * 1200;
			} else {
				team[tid].wrong[pid]++;
			}
		}

		sort(team+1, team+T+1);

		for (int i = 1; i <= T; i++) {
			cout << team[i].tid << ' ' << team[i].correct << ' ' << team[i].penalty << endl;
		}

	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <map>
#include <vector>
#include <functional>
#include <queue>

using namespace std;

typedef pair<int, int> P;
typedef pair<int, P> P2;

int main(){
  P2 team[51];
  int wrongCount[51][11];
  
  string message;
  int T, P, R;
  int Tid, Pid, time;
  
  while(cin >> T >> P >> R){
    if(T == 0 && P == 0 && R == 0) break;
    
    memset(wrongCount, 0, sizeof(wrongCount));
    
    for(int i = 0 ; i < T ; i++){
      team[i].first = 0; // Correct count
      team[i].second.first = 0; // time count
      team[i].second.second = i+1; // team number
    }

    for(int i = 0 ; i < R ; i++){
      cin >> Tid >> Pid >> time >> message;
      
      Tid--;
      
      if(message == "CORRECT"){
	team[Tid].first++;
	team[Tid].second.first += wrongCount[Tid][Pid]*1200 + time;
      }
      else if(message == "WRONG") wrongCount[Tid][Pid]++;
    }
    
    for(int i = 0 ; i < T ; i++){
      team[i].second.first *= -1;
      team[i].second.second *= -1;
    }
    
    sort(team, team+T);
    reverse(team, team+T);
  
    for(int i = 0 ; i < T ; i++){
      printf("%d %d %d\n", team[i].second.second*=-1, team[i].first, team[i].second.first*=-1);
    }
  }
  return 0;
}

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

using namespace std;

int main()
{
    int T, p, r;
    
    while (scanf("%d %d %d", &T, &p, &r) && T){
        bool done[128][128] = {0};
        int wa[128][128] = {0};
        pair<int, pair<int, int> > t[128];
        
        for (int i = 1; i <= T; i++){
            t[i].first = t[i].second.first = 0;
            t[i].second.second = i;
        }
        for (int i = 0; i < r; i++){
            int a, b, c;
            char d[128];
            scanf("%d %d %d %s", &a, &b, &c, d);
            
            if (d[0] == 'W'){
                wa[a][b]++;
            }
            else {
                if (done[a][b]) continue;
                done[a][b] = true;
                t[a].first--;
                t[a].second.first += wa[a][b] * 1200 + c;
            }
        }
        
        sort(t + 1, t + 1 + T);
        
        for (int i = 1; i <= T; i++){
            printf("%d %d %d\n", t[i].second.second, -t[i].first, t[i].second.first);
        }
    }
    
    return (0);
}