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 <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

struct data{
    int team, solve, penalty;
    data(int team, int solve, int penalty): team(team), solve(solve), penalty(penalty){}
};

bool cmp(data d1, data d2){
    if(d1.solve == d2.solve){
        if(d1.penalty == d2.penalty) return d1.team < d2.team;
        return d1.penalty < d2.penalty;
    }
    return d1.solve > d2.solve; 
}

signed main(){
    int t, p, r;
    while(1){
        cin >> t >> p >> r;
        if(t + p + r == 0) break;
        int tid, pid, time;
        string message;
        vector<data> d(t,data(0,0,0));
        rep(i, 0, t){
            d[i].team = i;
            d[i].solve = 0;
            d[i].penalty = 0;
        }
        int l[51][11]={0};
        rep(i, 0, r){
            cin >> tid >> pid >> time >> message;
            tid --;
            pid --;
            if(message == "CORRECT" && l[tid][pid] != -1){
                d[tid].solve ++;
                d[tid].penalty += time + 1200*l[tid][pid];
                l[tid][pid] = -1;
            }else if(message == "WRONG" && l[tid][pid] != -1){
                l[tid][pid] ++;
            }
        }
        sort(all(d), cmp);
        rep(i, 0, t){
            cout << d[i].team + 1 << " " << d[i].solve << " " << d[i].penalty <<endl;
        }
    }
}

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 <iostream>
#include <vector>
#include <algorithm>
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;

struct teamscore{
  int t, c, p;
};

bool comp(const teamscore &a, const teamscore &b)
{
  if(a.c != b.c)
    return a.c > b.c;
  else if(a.p != b.p)
    return a.p > b.p;
  else
    return a.t < b.t;
}

int main()
{
  while(1){
    int T, P, R;
    cin >> T >> P >> R;
    if(T == 0 && P == 0 && R == 0) break;
    vector<teamscore> v(T);
    REP(i,T){
      v[i].t = i+1;
      v[i].c = v[i].p = 0;
    }
    REP(i,R){
      int team, p, time;
      string m;
      cin >> team >> p >> time >> m;
      if(m == "WRONG"){
        v[team-1].p += 1200;
      }else{
        v[team-1].p += time;
        v[team-1].c++;
      }
    } 
    sort(v.begin(), v.end(), comp);
    REP(i,T)
      cout << v[i].t << " " << v[i].c << " " << v[i].p << endl;
  }
}

C++: #include<iostream>
#include<string>
using namespace std;

int main(){
	int t,p,r;
	while(true){
		cin >> t >> p >> r;
		if(t==0&&p==0&&r==0){
			break;
		}

		int miss[10][50]={0};
		int point[50]={0};
		int anscount[50]={0};

		for(int i=0;i<r;i++){
			int id,pid,time;
			string mes;
			cin >> id >> pid >> time >> mes;
			if(mes == "CORRECT"){
				point[id-1] += time +miss[pid-1][id-1] * 1200;
				anscount[id-1]++;
			}else{
				miss[pid-1][id-1]++;
			}
		}

		int id[50];
		for(int i=0; i < t; ++i) id[i] = i+1;
		for(int i=0; i < t; i++) {
			for(int j=i+1; j < t; j++) {
				if(anscount[i] < anscount[j]){
					swap(anscount[i], anscount[j]);
					swap(point[i], point[j]);
					swap(id[i], id[j]);
				}else if(anscount[i] == anscount[j]) {
					if(point[i] > point[j]) {
						swap(anscount[i], anscount[j]);
						swap(point[i], point[j]);
						swap(id[i], id[j]);
					}else if(point[i] == point[j] && id[i] > id[j]) {
						swap(anscount[i], anscount[j]);
						swap(point[i], point[j]);
						swap(id[i], id[j]);
					}
				}
			}
		}

		for(int i=0;i<t;i++){
			cout << id[i] << " " << anscount[i] << " " <<  point[i] << endl;
		}
	}
}