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<string>
using namespace std;

class Info
{
    private:
        int co_cnt, unco_cnt, pena;
    public:
        Info();
        int getCcnt() { return co_cnt; }
        int getPena() { return pena; }
        void wrongProcessing() { unco_cnt++; }
        void correctProcessing( int time );
};

class Sum
{
    private:
        int correct_sum;
        int pena_sum;
        int team;
    public:
        Sum() { correct_sum = 0; pena_sum = 0; team = 0; };
        int getCorrectSum(){ return correct_sum; }
        int getPenaSum(){ return pena_sum; }
        int getTeam(){ return team; }
        void setCorrectSum( int a ) { correct_sum = a; }
        void setPenaSum( int a ) { pena_sum = a; }
        void setTeam( int a ) { team = a; }
};

Info::Info()
{
    co_cnt = 0;
    unco_cnt = 0;
    pena = 0;
}

void Info::correctProcessing( int time )
{
    if( co_cnt == 1 )
        return;
    pena += unco_cnt * 1200 + time;
    co_cnt = 1;
    unco_cnt = 0;
}

void swap( Sum& a, Sum& b );
void bubbleSort( Sum* a, int n, int k );

int main()
{
    int t, p, s;
    string c;

    while( cin >> t >> p >> s )
    {
        if( t + p + s == 0 )
            break;
        
        Info a[t][p];

        for( int i = 0; i < s; i++ )
        {
            int x, y, z;
            cin >> x >> y >> z >> c;

            if( c == "WRONG" )
                a[x-1][y-1].wrongProcessing();
            else
                a[x-1][y-1].correctProcessing( z );
        }

        Sum b[t];
        for( int i = 0; i < t; i++ )
        {
            int x = 0, y = 0;
            for( int j = 0; j < p; j++ )
            {
                x += a[i][j].getCcnt();
                y += a[i][j].getPena();
            }
            b[i].setCorrectSum( x );
            b[i].setPenaSum( y );
            b[i].setTeam( i + 1 );
        }

        bubbleSort( b, t, 0 );
        bubbleSort( b, t, 1 );
        bubbleSort( b, t, 2 );

        for( int i = 0; i < t; i++ )
            cout << b[i].getTeam() << " " << b[i].getCorrectSum() << " " << b[i].getPenaSum() << endl;

    }
    
    return 0;
}

void swap( Sum& a, Sum& b )
{
    Sum c = a;
    a = b;
    b = c;
}

void bubbleSort( Sum* a, int n, int k )
{
    for( int i = 0; i < n; i++ )
    {
        for( int j = n - 1; j > i; j-- )
        {
            if( k == 0 && a[j].getCorrectSum() > a[j-1].getCorrectSum() )
                swap( a[j], a[j-1] );
            if( k == 1 && a[j].getCorrectSum() == a[j-1].getCorrectSum() && a[j].getPenaSum() < a[j-1].getPenaSum() )
                swap( a[j], a[j-1] );
            if( k == 2 && a[j].getCorrectSum() == a[j-1].getCorrectSum() && a[j].getPenaSum() == a[j-1].getPenaSum() && a[j].getTeam() < a[j-1].getTeam() )
                swap( a[j], a[j-1] );
        }
    }
}

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

struct Data{
  
  int team_num;
  int c_num;
  int p_time;
  int w_num[11];
  
  bool operator<(const Data& data)const{
    if(data.c_num != c_num)return c_num > data.c_num;
    if(data.p_time != p_time)return p_time < data.p_time;
    return team_num < data.team_num;
  }
  
};
void Init(Data *list,int T,int P){
  
  for(int i=1 ; i <= T ; i++){
    list[i].team_num = i;
    list[i].c_num = 0;
    list[i].p_time = 0;
    for(int j=1 ; j <= P ; j++){
      list[i].w_num[j] = 0;
    }
  }
  
}
void Correct(Data *list,int tID,int pID,int time){
  
  list[tID].c_num++;
  list[tID].p_time+=(1200*list[tID].w_num[pID])+time;
  
}
void Wrong(Data *list,int tID,int pID){
  
  list[tID].w_num[pID]++;
  
}
int main(){
  
  int T,P,R;
  int tID,pID,time;
  string message;
  
  while(1){
    
    cin >>T>>P>>R;
    if(T==0 && P==0 && R==0)break;
    
    Data list[T+1];
    
    Init(list,T,P);
    
    for(int i=0 ; i < R ; i++){
      cin >>tID>>pID>>time>>message;
      if(message == "CORRECT"){
	Correct(list,tID,pID,time);
      }else{
	Wrong(list,tID,pID);
      }  
    }
    
    sort(list+1,list+T+1);
    
    for(int i=1 ; i <= T ; i++){
      cout <<list[i].team_num<<" "<<list[i].c_num<<" "<<list[i].p_time<<endl;
    }
    
  }
  
  return 0;
}