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 <stdio.h>
#include <string.h>
#include <algorithm>

using namespace std;

int main(void){
	int t, p, r, tid, pid, time, i, j, k, flag[50][10], pena[50][10], max, sum, max_i, min_i, count, num[50], solvep[50], solvet[50], head, tail;
	char message[8], c;
	int tmp1, tmp2, tmp3;
	const char correct[8] = {"CORRECT"},wrong[6] = {"WRONG"};
	while(1){
		scanf("%d%d%d",&t,&p,&r);
		if(t == 0 && p == 0 && r == 0)
			break;
		memset(pena,0,sizeof(pena));
		memset(flag,0,sizeof(flag));
		for(i = 0;i < r;i++){
			scanf("%d%d%d%*c",&tid,&pid,&time);
			j = 0;
			while((c = getchar()) != '\n')
				message[j++] = c;
			message[j] = '\0';
			if(!flag[tid - 1][pid - 1]){
				if(!strncmp(correct,message,7))
					flag[tid - 1][pid - 1] = 1200 * pena[tid - 1][pid - 1] + time;
				else if(!strncmp(wrong,message,5))
					pena[tid - 1][pid - 1]++;
			}
		}
		for(i = 0;i < t;i++)
			num[i] = i + 1;
		for(i = 0;i < t;i++){
			count = 0;
			for(j = 0;j < p;j++){
				if(flag[i][j])
					count++;
			}
			solvep[i] = count;
		}
		for(i = 0;i < t;i++){
			sum = 0;
			for(j = 0;j < p;j++)
				sum += flag[i][j];
			solvet[i] = sum;
		}

		for(i = 0;i < t - 1;i++){
			max_i = i;
			for(j = i + 1;j < t;j++){
				if(solvep[max_i] < solvep[j])
					max_i = j;
			}
			if(max_i != i){
				tmp1 = num[max_i];
				tmp2 = solvep[max_i];
				tmp3 = solvet[max_i];
				num[max_i] = num[i];
				solvep[max_i] = solvep[i];
				solvet[max_i] = solvet[i];
				num[i] = tmp1;
				solvep[i] = tmp2;
				solvet[i] = tmp3;
			}
		}
		for(i = 10;i >= 0;i--){
			for(j = 0;j < t;j++){
				if(solvep[j] == i){
					k = j + 1;
					while(solvep[k] == i)
						k++;
					break;
				}
			}
			if(j == t)
				continue;
			head = j;
			tail = k - 1;
			for(j = head;j <= tail - 1;j++){
				min_i = j;
				for(k = j + 1;k <= tail;k++){
					if(solvet[min_i] > solvet[k])
						min_i = k;
				}
				if(min_i != j){
					tmp1 = num[min_i];
					tmp2 = solvep[min_i];
					tmp3 = solvet[min_i];
					num[min_i] = num[j];
					solvep[min_i] = solvep[j];
					solvet[min_i] = solvet[j];
					num[j] = tmp1;
					solvep[j] = tmp2;
					solvet[j] = tmp3;
				}
			}
		}
		for(i = 0;i < t - 1;i++){
			for(j = i + 1;j < t;j++){
				if(solvep[i] == solvep[j] && solvet[i] == solvet[j])
					continue;
				break;
			}
			sort(num + i, num + j);
		}
		for(i = 0;i < t;i++)
			printf("%d %d %d\n",num[i],solvep[i],solvet[i]);
	}
	return 0;
}

C++: //
//  main.cpp
//  c
//
//  Created by 13B10694 on 2015/06/01.
//  Copyright (c) 2015????´ 13B10694. All rights reserved.
//

#include <iostream>
#include <vector>
#include<stdio.h>
#include <algorithm>
#include<string.h>
using namespace std;

int now=1;

class team{
    
public:
    int id, pen, sol;
    int wrong[12];
    vector <int> solved;
    team(){
        memset(wrong, 0, sizeof(wrong));
        id=now++;
        pen=0;sol=0;
    }
    ~team(){
        solved.clear();
    }
    
    bool operator < (const team& b) const
    {
        return solved.size()==b.solved.size() ? pen== b.pen ? id<b.id : pen<b.pen : solved.size()>b.solved.size();
    }
};

int main() {
    int t,p,r;
    while(cin>>t>>p>>r,t){
        now=1;
        vector<team> tea(t);

        for(int i=0;i<r;i++){
            int ti, pi, tim;
            string mes;
            cin>>ti>>pi>>tim>>mes;
            ti-=1;
            if(mes=="WRONG"){
                tea[ti].wrong[pi]++;
                continue;
            }
            if(find(tea[ti].solved.begin(),tea[ti].solved.end(),pi)!=tea[ti].solved.end()){
                continue;
            }
            tea[ti].solved.push_back(pi);
            tea[ti].pen += tea[ti].wrong[pi]*1200+tim;
  
        }
        sort(tea.begin(),tea.end());
        for(int i=0;i<t;i++){
            cout<<tea[i].id<<" "<<tea[i].solved.size()<<" "<<tea[i].pen<<endl;
        }
       tea.clear();
    }
    
    return 0;
}

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

struct Problem {
	int num_wrong;

	Problem() : num_wrong(0) {}
};

struct Team {
	int team;
	std::vector<Problem> problems;
	int num_correct;
	int penalty;

	Team(int team, int num_problems)
		: team(team),
		problems(num_problems),
		num_correct(0),
		penalty(0)
	{}
};

int main()
{
	std::vector<Team> teams;
	std::string message;
	message.reserve(8);

	while (true) {
		int num_teams, num_problems, num_records;
		std::cin >> num_teams >> num_problems >> num_records;

		if (num_teams == 0) return 0;

		teams.clear();
		teams.reserve(num_teams);
		for (int i = 1; i <= num_teams; i++)
			teams.push_back(Team(i, num_problems));

		for (int i = 0; i < num_records; i++) {
			int tid, pid, time;
			std::cin >> tid >> pid >> time >> message;

			Team& t = teams[tid - 1];
			Problem& p = t.problems[pid - 1];

			switch (message[0])
			{
			case 'C':
				t.penalty += p.num_wrong * 1200 + time;
				t.num_correct++;
				break;
			case 'W':
				p.num_wrong++;
				break;
			default:
				return 1;
			}
		}

		std::sort(teams.begin(), teams.end(), [](Team& x, Team& y) {
			if (x.num_correct > y.num_correct) return true;
			if (x.num_correct < y.num_correct) return false;
			if (x.penalty < y.penalty) return true;
			if (x.penalty > y.penalty) return false;
			return x.team < y.team;
		});

		for (Team& t : teams) {
			std::cout << t.team << " " << t.num_correct << " " << t.penalty << std::endl;
		}
	}
}