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 <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cctype>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <memory>
#include <functional>
#include <set>
#include <iomanip>

using namespace std;

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < (int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define INF 1<<25
#define pb push_back
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
typedef long long ll;

int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};

#define MAX 1500

int main()
{
    int t,p,r;
    while(cin >>t >> p >> r,t,p,r){
        vector<int>tID;
        vector<int>pID;
        vector<int>time;
        vector<string>com;
        
        for(int i=0;i<r;i++){
            int a,b,c;
            string d;
            cin >> a >> b >> c >> d;
            tID.pb(a);
            pID.pb(b);
            time.pb(c);
            com.pb(d);
        }
        for(int i=0;i<t;i++){
            for(int j=i+1;j<t;j++){
                if(pID[i] > pID[j]){
                    swap(pID[i],pID[j]);
                    swap(tID[i],tID[j]);
                    swap(time[i],time[j]);
                    swap(com[i],com[j]);
                }
                
            }
        }
        /*
        for(int i=0;i<r;i++){
            cout << "tID:" <<tID[i] << " pID:" << pID[i] << " time:" << time[i] << " judge:" << com[i] <<  endl;
        }
         
         */
        vector<vector<int> > ans;
        vi temp;
        for(int i=0;i<t;i++){
            temp.pb(i+1);
            for(int j=1;j<5;j++){
                temp.pb(0);
            }
            ans.pb(temp);
            temp.clear();
        }
        
        for(int i=0;i<r;i++){
            if(com[i] == "CORRECT"){
                ans[tID[i]-1][1]++;
                ans[tID[i]-1][2] += (ans[tID[i]-1][3] * 1200 + time[i]);
//                cout << "tID:" << ans[tID[i]-1][0] << "??£?????°:" << ans[tID[i]-1][1] << "??????" << ans[tID[i]-1][2] << endl;
                if(ans[tID[i]-1][3]>0){
                    ans[tID[i]-1][3] = 0;
                    ans[tID[i]-1][4]--;
                }
            }else{
                ans[tID[i]-1][3]++;
                ans[tID[i]-1][4]++;
            }
            
        }
        for(int i=0;i<t;i++){
            for(int j=i+1;j<t;j++){
                if(ans[i][1] < ans[j][1]){
                    swap(ans[i][0],ans[j][0]);
                    swap(ans[i][1],ans[j][1]);
                    swap(ans[i][2],ans[j][2]);
                    swap(ans[i][3],ans[j][3]);
                    swap(ans[i][4],ans[j][4]);
                }
                
                if(ans[i][1] == ans[j][1] && ans[i][4] > ans[j][4]){
                    swap(ans[i][0],ans[j][0]);
                    swap(ans[i][1],ans[j][1]);
                    swap(ans[i][2],ans[j][2]);
                    swap(ans[i][3],ans[j][3]);
                    swap(ans[i][4],ans[j][4]);
                }
                
                if(ans[i][1] == ans[j][1] && ans[i][4] == ans[j][4] && ans[i][0] > ans[j][0] ){
                    swap(ans[i][0],ans[j][0]);
                    swap(ans[i][1],ans[j][1]);
                    swap(ans[i][2],ans[j][2]);
                    swap(ans[i][3],ans[j][3]);
                    swap(ans[i][4],ans[j][4]);
                }
                if(ans[i][1] == ans[j][1] && ans[i][2] == ans[j][2] && ans[i][0] > ans[j][0] ){
                    swap(ans[i][0],ans[j][0]);
                    swap(ans[i][1],ans[j][1]);
                    swap(ans[i][2],ans[j][2]);
                    swap(ans[i][3],ans[j][3]);
                    swap(ans[i][4],ans[j][4]);
                }
            }
        }

        
        for(int i=0;i < t;i++){
               cout << ans[i][0] << " " << ans[i][1] <<" " << ans[i][2] << endl;
        }
    }
    return 0;
}

C++: #include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
typedef pair<ll, int> Pll;
int main()
{
  int T, P, R;
  while(cin >> T >> P >> R, T || P || R) {
    ll point[T+1], miss[T+1][P+1], pena[T+1];
    CLR(pena), CLR(miss), CLR(point);
    FOR(i,0,R) {
      int in[3]; FOR(j,0,3) cin >> in[j];
      string mes; cin >> mes;
      if(mes[0] == 'C') {
        point[in[0]]++;
        pena[in[0]] += miss[in[0]][in[1]] * 1200 + in[2];
      } else {
        miss[in[0]][in[1]]++;
      }
    }
    vector<Pll> sum_point(T);
    FOR(i,0,T) {
      ll p = point[i+1] * 1000000 - pena[i+1] * 10 - i;
      sum_point[i] = Pll(p, i + 1);
    }
    sort(sum_point.rbegin(), sum_point.rend());
    FOR(i,0,T) {
      int j = sum_point[i].second;
      cout << j << " " << point[j] << " " << pena[j] << endl;
    }
  }
  return 0;
}