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 <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;


bool cmp(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[64];
    rep(i, T) t[i] = make_pair(i+1, make_pair(0, 0));
    rep(i, R){
      scanf("%d%d%d", &tid, &pid, &time);
      tid--;
      scanf("%s", message);
      if(message[0] == 'C'){
	  t[tid].second.first += 1;
	  t[tid].second.second += fail[tid][pid] * 1200 + time;
	  fail[tid][pid] = -1;
      }else  fail[tid][pid]++;
    }
    sort(t.begin(), t.end(), cmp);
    rep(i, T) printf("%d %d %d\n", t[i].first, t[i].second.first, t[i].second.second);
  }
  return 0;
}

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;


bool cmp(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+1);
    int fail[11][11] = {};
    int tid, pid, time;
    char message[64];
    rep(i, T+1) t[i] = make_pair(i, make_pair(0, 0));
    rep(i, R){
      scanf("%d%d%d", &tid, &pid, &time);

      scanf("%s", message);
      if(message[0] == 'C'){
	  t[tid].second.first += 1;
	  t[tid].second.second += fail[tid][pid] * 1200 + time;
	  fail[tid][pid] = -1;
      }else  fail[tid][pid]++;
    }
    sort(t.begin(), t.end(), cmp);
    rep(i, T+1) if(t[i].first) printf("%d %d %d\n", t[i].first, t[i].second.first, t[i].second.second);
  }
  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

struct state{
  int AC, penalty, team;
};

bool comp(state s1, state s2) {
  if(s1.AC != s2.AC) return s1.AC > s2.AC;
  else if(s1.penalty != s2.penalty) return s1.penalty < s2.penalty;
  else return s1.team < s2.team;
}

int main(){
  int T, P, R;
  while(cin >> T >> P >> R && T) {
    vector<state> a(T);
    REP(i, T) a[i] = (state){0, 0, i + 1};
    vector<vector<int>> flag(T, vector<int> (P, 0));
    REP(r,R) {
      int tID, pID, time;
      string msg;
      cin >> tID >> pID >> time >> msg;
      tID--;
      pID--;
      if(msg == "CORRECT") {
        if(flag[tID][pID] == -1) continue;
        a[tID].AC++;
        a[tID].penalty += flag[tID][pID] * 1200 + time;
        flag[tID][pID] = -1;
      }else if(msg == "WRONG"){
        if(flag[tID][pID] == -1) continue;
        flag[tID][pID]++;
      }
    }
    sort(ALL(a), comp);
    REP(i,T) {
      cout << a[i].team << " " << a[i].AC << " " << a[i].penalty << endl;
    }
  }
  return 0;
}

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

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

using namespace std;

int main() {
  while(1){
    int t,p,r;
    cin>>t>>p>>r;
    if(!t)break;
    vector<vector<int>> v(t,vector<int>(p));
    REP(i,r){
      int tid,pid,time;
      string str;
      cin>>tid>>pid>>time>>str;
      --tid;--pid;
      if(str=="WRONG"){
        if(v[tid][pid]<=0)
          --v[tid][pid];
      }else{
        if(v[tid][pid]<=0){
          v[tid][pid] = time - v[tid][pid] * 1200;
        }
      }
    }
    vector<tuple<int,int,int>> sc;
    REP(i,t){
      int ac=0;
      int pen=0;
      REP(j,p){
        if(v[i][j]>0){
          ++ac;
          pen += v[i][j];
        }
      }
      sc.emplace_back(-ac,pen,i+1);
    }
    sort(begin(sc),end(sc));
    for(auto tp:sc){
      cout << get<2>(tp) << ' ' << -get<0>(tp) << ' ' << get<1>(tp) << endl;
    }
  }
  return 0;
}