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>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define eb emplace_back

int in(){int x;cin>>x;return x;}
main(){
    while(1){
        int t=in();
        int p=in();
        int r=in();
        if(!t and !p and !r)exit(0);
        vector<vector<int>> pen(t,vector<int>(p));
        vector<int> T(t),cnt(t);
        rep(i,r){
            int id=in()-1;
            int pid=in()-1;
            int tim=in();
            string val;cin>>val;
            if(val[0]=='C'){
                T[id]+=tim;
                T[id]+=pen[id][pid]*1200;
                cnt[id]++;
            }
            else pen[id][pid]++;
        }
        vector<int> id(t);
        iota(id.begin(),id.end(),0);
        sort(id.begin(),id.end(),[&](int x,int y){
            if(cnt[x]!=cnt[y]) return cnt[x]>cnt[y];
            else if(T[x]!=T[y]) return T[x]<T[y];
            else return x<y;
        });
        rep(i,t){
            cout<<id[i]+1<<" "<<cnt[id[i]]<<" "<<T[id[i]]<<endl;
        }
    }
}

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

using namespace std;

int main(void){
    int T,P,R;
    cin >> T >> P >> R;
    while(T){
        int tid, pid, tim;
        string mes;
        int wa[T+1][P+1];
        fill(wa[0], wa[T+1], 0);
        vector< pair< pair<int, int>, int> > result(T+1);
        for(int i=0;i<T+1;i++){
            result[i].first.first = 0;
            result[i].first.second = 0;
            result[i].second = i;
        }
        for(int i=0;i<R;i++){
            cin >> tid >> pid >> tim >> mes;
            if(mes[0] == 'C'){
                result[tid].first.second += wa[tid][pid] * 1200 + tim;
                result[tid].first.first--;
            }else{
                wa[tid][pid]++;
            }
        }

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

        for(int i=0;i<=T;i++){
            if(result[i].second == 0) continue;
            printf("%d %d %d\n", result[i].second, -result[i].first.first, result[i].first.second);
        }
        cin >> T >> P >> R;
    }
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)

struct Info
{
    int solved, time, tid, wrong[11];
    bool operator< (const Info &rhv) const {
        return solved == rhv.solved ?
        (time == rhv.time ? tid < rhv.tid : time < rhv.time) :
        solved > rhv.solved;
    }
};

int main()
{
    int T, P, R, tid, pid, time;
    string msg;
    Info info[55];
    
    while(cin >> T >> P >> R && T)
    {
        memset(info, 0, sizeof(info));
        rep(i, T) info[i].tid = i + 1;
        rep(i, R)
        {
            cin >> tid >> pid >> time >> msg;
            --tid;
            if(msg == "CORRECT") {
                ++info[tid].solved;
                info[tid].time += time + 1200 * info[tid].wrong[pid];
            } else
                ++info[tid].wrong[pid];
        }
        sort(info, info + T);
        rep(i, T) {
            cout << info[i].tid << ' ' << info[i].solved << ' ' << info[i].time << endl;
        }
    }
}

C++: #include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define between(a,x,b) ((a)<=(x)&&(x)<=(b))
using namespace std;
typedef pair<int, pair<int, int> > tpair;

/*struct hoge{
  bool operator()(const tpair& a, const tpair& b){
    if(a.second.first != b.second.first) return a.second.first > b.second.first;
    else if(a.second.second != b.second.second) return a.second.second < b.second.second;
    else return a.first < b.first;
  }
}; */

int main(){
  int T, P, R;
  while(scanf("%d%d%d", &T, &P, &R) && (T||P||R)){
    //    vector<pair<int, pair<int, int> > > t(T); // team ac p
    vector<tpair> t(T);
    int fail[11][11] = {};
    int tid, pid, time;
    char message[16];
    rep(i, T) t[i].first = i+1;     
/*    rep(i, R){
      scanf("%d%d%d%s", &tid, &pid, &time, message); tid--; pid--;
      if(message[0] == 'C'){
	if(fail[tid][pid] != -1){
	  t[tid].second.first++;
	  t[tid].second.second += fail[tid][pid] * 1200 + time;
	  fail[tid][pid] = -1;
	}
      }else if(message[0] == 'W'){
	if(fail[tid][pid] != -1)
	  fail[tid][pid]++;
      }
    } */
    sort(t.begin(), t.end());
    rep(i, T) printf("%d %d %d\n", t[i].first, t[i].second.first, t[i].second.second);
  }
  return 0;
}