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+1);
    int fail[64][64] = {};
    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 <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <sstream>
#include <numeric>
#include <set>
#include <map>

#define rep(i, j) for(int i = 0; i < j; i++)
#define all(i) i.begin(), i.end()

using namespace std;

struct dat_st{ int ac, pn, tid; };
bool compare(dat_st &t0, dat_st &t1)
{
    if (t0.ac == t1.ac) 
    {
		if(t0.pn == t1.pn){ return t0.tid > t1.tid; }
        return t0.pn > t1.pn; 
    }
    return t0.ac < t1.ac;
}
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int T, P, R; while( cin >> T >> P >> R && T != 0)
	{
		vector<dat_st> dat(T + 1);
		vector<vector<int>> wr(T + 2, vector<int>(P + 2, 0));
		rep(i, R)
		{
			int tid, pid, tm; cin >> tid >> pid >> tm;
			string ms; cin >> ms;
			rep(j, T){ dat[j + 1].tid = j + 1; }
			if( ms == "CORRECT" )
			{
				dat[tid].ac += 1;
				dat[tid].pn += wr[tid][pid] * 1200 + tm; 
			}
			else{ wr[tid][pid] += 1; }
		}
		dat.erase(dat.begin());
		sort(dat.rbegin(), dat.rend(), compare);
		rep(i, T){ printf("%d %d %d\n", dat[i].tid, dat[i].ac, dat[i].pn); }
	}
	return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;
using ll=long long;
template <class T> using vec=vector<T>;
template <class T> using vvec=vec<vec<T>>;
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define en "\n"

void solve(ll t,ll p,ll r){
    vvec<ll> wa(t,vec<ll> (p,0));
    vvec<ll> pena(t,vec<ll> (p,-1));

    REP(i,r){
        ll tt,pp,time;
        string s;
        cin>>tt>>pp>>time>>s;
        tt--;pp--;
        if(s=="CORRECT"){
            if(pena[tt][pp]==-1){
                pena[tt][pp]=1200*wa[tt][pp]+time;
            }
        }else{
            wa[tt][pp]++;
        }
    }

    vec<pair<ll,pair<ll,ll>>> num;
    REP(tt,t){
        ll ac=0,pen=0;
        REP(pp,p){
            if(pena[tt][pp]!=-1){
                ac++;
                pen+=pena[tt][pp];
            }
        }
        num.push_back({-ac, {pen,(ll)tt}});
    }

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

    for(auto i:num){
        ll ac=i.first;
        ll pen=i.second.first;
        ll tt=i.second.second;
        cout<<tt+1<<" "<<-ac<<" "<<pen<<en;
    }
}

int main(void){
    while(true){
        ll a,b,c;
        cin>>a>>b>>c;
        if(a==0)break;
        solve(a,b,c);
    }
    return 0;
}

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

struct team{
	int num;
	int ans;
	double time;
};

bool hikaku(const team &right,const team &left){
	return right.ans == left.ans ? right.time < left.time : right.ans > left.ans;
}

int main(){
	int t,p,r;
	int wrong[52][12];
	int res[52];
	double pe[52];
	vector<team> v;
	int tid,pid,time;
	string message;
	team te;
	while(1){
		cin >> t >> p >> r;
		if(t == 0)break;
		for(int i = 0;i <= t;i++){
			res[i] = 0;
			pe[i] = 0;
			for(int j = 0;j <= p;j++){
				wrong[i][j] = 0;	
			}
		}
		v.clear();
		for(int i = 0;i < r;i++){
			cin >> tid >> pid >> time >> message;
			if(message == "CORRECT"){
				res[tid]++;
				pe[tid] += wrong[tid][pid] * 1200 + time;
			}
			else if(message == "WRONG"){
				wrong[tid][pid]++;
			}
		}
		for(int i = 1;i <= t;i++){
			te.num = i;
			te.ans = res[i];
			te.time = pe[i];
			v.push_back(te);
		}
		sort(v.begin(),v.end(),hikaku);
		for(int i = 0;i < v.size();i++){
			cout << v[i].num << " " << v[i].ans << " " << v[i].time <<endl;
		}
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <complex>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <stack>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <cassert>

using namespace std;

typedef long long ll;
typedef ll li;
typedef pair<int,int> PI;
#define EPS (1e-10L)
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define F first
#define S second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int)((a).size())
#define ALL(a) a.begin(),a.end()
#define FOR(it,a) for(__typeof(a.begin())it=a.begin();it!=a.end();++it)
void pkuassert(bool t){t=1/t;};

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

int t,p,r;

void solve(){
  map<int,PI> app;
  rep(i,t) app[i+1]=mp(0,0);
  map<PI,int> tr;
  set<PI> ok;
  rep(i,r){
    int tid,pi,ti;
    string s;
    cin >> tid >> pi >> ti >> s;
    if(ok.count(mp(tid,pi))) continue;
    if(s[0]=='W'){
      tr[mp(tid,pi)]++;
    }else{
      ++app[tid].F;
      app[tid].S+=ti+tr[mp(tid,pi)]*1200;
      ok.insert(mp(tid,pi));
    }
  }
  vector<pair<PI,int> > team;
  FOR(it,app) team.pb(mp(mp(-it->S.F,it->S.S),it->F));
  sort(ALL(team));
  FOR(it,team) cout << it->S << ' ' << -it->F.F << ' ' << -it->F.S << endl;
}

int main(int argc, char *argv[])
{
  while(cin >> t >> p >> r && t|p|r) solve();
  return 0;
}