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;

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(), hoge());
    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 <cstdlib>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <cstring>
#include <cctype>
#include <sstream>
#include <set>
#include <map>
#include <queue>
#include <complex>
using namespace std;
#define REP(i,n) for(int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for(int i = a; i < (int)b; i++)
const int INF = 1<<28;

bool com(const pair<int, pair<int, int> >& left, const pair<int, pair<int, int> >& right) {
	if(left.second.first == right.second.first) {
		if(left.second.second == right.second.second)
			return left.first < right.first;
		else
			return left.second.second < right.second.second;
	}
	else
		return left.second.first > right.second.first;
}

int main() {
	int T, P, R;
	while(cin >> T >> P >> R, T|P|R) {
		vector< pair<int, pair<int, int> > > vp;
		multiset<int> w;
		REP(i, T)
			vp.push_back(make_pair(i+1, make_pair(0, 0)));
		REP(j, R) {
			int tid, pid, time;
			string message;
			cin >> tid >> pid >> time >> message;
			if(message == "CORRECT") {
					vp[tid-1].second.first++;
					vp[tid-1].second.second += w.count(tid * 100 + pid) * 1200 + time;
			}
			else if(message == "WRONG")
				w.insert(tid * 100 + pid);
		}
		sort(vp.begin(), vp.end(), com);
		REP(i, vp.size())
			cout << vp[i].first << ' ' << vp[i].second.first << ' ' << vp[i].second.second << endl; 
	}
	return 0;
}

C++: #include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <complex>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<double> VEC;
typedef vector<VEC> MAT;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define MT(a,b,c) MP(a, MP(b, c))
#define T1 first
#define T2 second.first
#define T3 second.second

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define EPS 1.0e-9

int wrong[55][11];

int main(){
	int t,p,r;
	while(cin>>t>>p>>r,t){
		memset(wrong, 0, sizeof(wrong));
		vector<TIII> v(t);
		REP(i,t)v[i]=MT(0,0,i+1);
		REP(i,r){
			int tid, pid, tt;
			string state;
			cin >> tid >> pid >> tt >> state;
			if(state=="CORRECT"){
				v[tid-1].T1 -= 1;
				v[tid-1].T2 += tt + wrong[tid-1][pid-1]*1200;
			}else wrong[tid-1][pid-1]++;
		}
		SORT(v);
		REP(i,t)cout << v[i].T3 << " "<< -v[i].T1 << " "<< v[i].T2 << endl;
	}
	return 0;
}