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++: #define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;

int n_correct[51] = {};
int pena[51] = {};


bool comp(const int l, const int r);
bool comp(const int l, const int r) {
	if (n_correct[l] > n_correct[r])
		return true;
	else if (n_correct[l] < n_correct[r])
		return false;
	else {
		if (pena[l] < pena[r])
			return true;
		else if (pena[l] > pena[r])
			return false;
		else {

			return l < r;
		}
	}
	
}



int main() {

	while (true) {
		int T, P, R;
		int n_wrong[51][11];
		for (int i = 0; i < 51; i++) {
			for (int j = 0; j < 11; j++) {
				n_wrong[i][j] = 0;
			}
			n_correct[i] = 0;
			pena[i] = 0;
		}
		scanf("%d", &T);
		scanf("%d", &P);
		scanf("%d", &R);
		if (T == 0 && P == 0 && R == 0)
			break;
		for (int i = 0; i < R; i++) {
			int tID, pID, time;
			char msg[20];
			scanf(" %d %d %d %s",&tID,&pID,&time,msg);

			if (msg[0] == 'C') {
				n_correct[tID]++;
				pena[tID] += 1200 * n_wrong[tID][pID] + time;

			}
			else {
				n_wrong[tID][pID]++;

			}
		}

		vector<int> rank;
		for (int t = 1; t <= T; t++) {
			rank.push_back(t);
		}
		sort(rank.begin(), rank.end(), comp);

		for (int i = 0; i < T; i++) {
			printf("%d %d %d\n", rank[i], n_correct[rank[i]], pena[rank[i]]);
		}

	}
}

C++: #include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main() {
	int t, p, r;
	while (cin >> t >> p >> r, t, p, r) {
		bool b[60][60] = {};
		int WA[60][60] = {};
		int point[60][2] = {};
		pair<int, pair<int, pair<int, string>>> a[514];
		for (int i = 0; i < r; i++) 
			cin >> a[i].second.first >> a[i].second.second.first >> a[i].first >> a[i].second.second.second;
		sort(a, a + r);
		for (int i = 0; i < r; i++) {
			if (b[a[i].second.first][a[i].second.second.first]);
			else if (a[i].second.second.second[0] == 'W') {
				WA[a[i].second.first][a[i].second.second.first]++;
			}
			else {
				point[a[i].second.first][0]++;
				point[a[i].second.first][1] += WA[a[i].second.first][a[i].second.second.first] * 1200 + a[i].first;
				b[a[i].second.first][a[i].second.second.first] = true;
			}
		}
		pair<int, pair<int, int>> a2[60];
		for (int i = 1; i <= t; i++) {
			a2[i].first = point[i][0];
			a2[i].second.first = point[i][1];
			a2[i].second.second = i;
		}
		for (int i = 1; i < t; i++) {
			for (int j = i + 1; j <= t; j++) {
				if (a2[i].first < a2[j].first)swap(a2[i], a2[j]);
				else if (a2[i].first == a2[j].first) {
					if (a2[i].second.first > a2[j].second.first)swap(a2[i], a2[j]);
					else if (a2[i].second.first == a2[j].second.first) {
						if (a2[i].second.second > a2[j].second.second)swap(a2[i], a2[j]);
					}
				}
			}
		}
		for (int i = 1; i <= t; i++) {
			cout << a2[i].second.second << ' ' << a2[i].first << ' ' << a2[i].second.first << endl;
		}
	}
}

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

using namespace std;

class Team{
public:
	int tid,correct,penalty;
	int wrong[11];
	bool operator< (const Team &opp) const{
		if(correct!=opp.correct) return correct>opp.correct;
		if(penalty!=opp.penalty) return penalty<opp.penalty;
		return tid<opp.tid;
	}
	Team();
	Team(int id);
};

Team::Team(){
	correct=0;penalty=0;
}
Team::Team(int id){
	tid=id;correct=0;penalty=0;
	for(int i=1;i<=10;i++)wrong[i]=0;
}

Team T[50];

int main(){
	int i,t,p,r;
	while(cin>>t>>p>>r, t){
		int tid, pid, time;
		string mes;
		for(i=1;i<=t;i++) T[i]=Team(i);
		while(r--){
			cin>>tid>>pid>>time>>mes;
			if(mes=="CORRECT"){
				T[tid].correct ++;
				T[tid].penalty += T[tid].wrong[pid]*1200+time;
			}else{
				T[tid].wrong[pid] ++;
			}
		}
		sort(T+1, T+1+t);
		for(i=1;i<=t;i++) cout<<T[i].tid<<" "<<T[i].correct<<" "<<T[i].penalty<<" "<<endl;
	}
}

C++: #include<iostream>
#include<string>
#include<vector>
#include<tuple>
#include<set>
#include<map>
#include<algorithm>
using namespace std;

struct Record {
  int tid, pid, time;
  bool correct;
};

struct Team {
  Team() {
    penalty = 0;
  }
  set<int> solved;
  map<int, int> WA;
  int penalty;
};

// Solved Problems, Penalty, Team ID
typedef tuple<int, int, int> Score;

int main() {
  int T, P, R;
  while (cin >> T >> P >> R && T) {
    vector<Record> records(R);
    for (int i = 0; i < R; i++) {
      int tid, pid, stime;
      string message;
      cin >> tid >> pid >> stime >> message;
      records[i].pid = --pid;
      records[i].tid = --tid;
      records[i].time = stime;
      records[i].correct = (message == "CORRECT");
    }

    vector<Team> teams(T);
    for (Record r : records) {
      if (teams[r.tid].solved.find(r.pid) != teams[r.tid].solved.end()) {
        continue;
      } else if (r.correct) {
        teams[r.tid].solved.insert(r.pid);
        teams[r.tid].penalty +=
          teams[r.tid].WA[r.pid] * 1200 + r.time;
      } else {
        teams[r.tid].WA[r.pid]++;
      }
    }

    vector<Score> team_result(T);
    for (int i = 0; i < T; i++) {
      get<0>(team_result[i]) = -teams[i].solved.size();
      get<1>(team_result[i]) = teams[i].penalty;
      get<2>(team_result[i]) = i;
    }

    sort(team_result.begin(), team_result.end());

    for (Score s : team_result) {
      cout << get<2>(s)+1 << " " << -get<0>(s) << " " << get<1>(s) << endl;
    }
  }
}