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 <vector>                                                                             
#include <algorithm>                                                                          
#include <string>                                                                             
using namespace std;                                                                          
typedef long long ll;                                                                         
                                                                                              
class TEAM{                                                                                   
  public:                                                                                     
    ll solved;                                                                                
    ll wrong;                                                                                 
    ll pen;                                                                                   
    ll id;                                                                                    
    vector<bool> problem;                                                                     
    TEAM(ll n){                                                                               
      solved = 0;                                                                             
      wrong = 0;                                                                              
      pen = 0;                                                                                
      problem = vector<bool>(n, false);                                                       
    }                                                                                         
    bool operator<(const TEAM &a)const{                                                       
      if(solved == a.solved){                                                                 
        return pen < a.pen;                                                                   
      }else{                                                                                  
        return solved > a.solved;                                                             
      }                                                                                       
    }                                                                                         
    bool operator==(const TEAM &a)const{                                                      
      return solved == a.solved && pen == a.pen;                                              
    }                                                                                         
};                                                                                            
                                                                                              
int main(void){                                                                               
  ll T, P, R;                                                                                 
  while(cin >> T >> P >> R, T | P | R){                                                       
    vector<TEAM> team(T, TEAM(P));                                                            
    for(ll i=0; i < T; i++){                                                                  
      team[i].id = i+1;                                                                       
    }                                                                                         
    while(R--){                                                                               
      ll tID, pID, time; string message;                                                      
      cin >> tID >> pID >> time >> message;                                                   
      tID--; pID--;                                                                           
      if(team[tID].problem[pID] == true) continue;                                            
      if(message == "CORRECT"){                                                               
        team[tID].problem[pID] = true;                                                        
        team[tID].solved++;                                                                   
        team[tID].pen += team[tID].wrong * 1200 + time;                                       
      }else{                                                                                  
        team[tID].wrong++;                                                                    
      }                                                                                       
    }                                                                                         
    stable_sort(team.begin(), team.end());                                                    
    for(ll i=0;  i< T; i++){                                                                  
      cout << team[i].id << " " << team[i].solved << " " << team[i].pen << endl;              
    }                                                                                         
  }                                                                                           
  return 0;                                                                                   
}