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 <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;

struct team{
  int tid;
  int pen;
  int ans;
};


bool comp (const struct team x1,const struct team x2)
{
  if(x1.ans>x2.ans)
    return true;
  else if(x1.ans<x2.ans)
    return false;
  else
    {
      if(x1.pen<x2.pen)
	return true;
      else if(x1.pen>x2.pen)
	return false;
      else
	{
	  if(x1.tid<x2.tid)
	    return true;
	  else if(x1.tid>x2.tid)
	    return false;
	}
      
    }
}


int main()
{
  int t,p,r;
  while(true)
    {
      cin>>t;
      cin>>p;
      cin>>r;
      if(t==0)
	exit(0);

      vector<team> d;
      d.clear();
      for(int i=0;i<t;i++)
	{
	  struct team x;
	  x.tid=i+1;
	  x.pen=0;
	  x.ans=0;
	  d.push_back(x);
	}
      int miss[99][99]={0};

      for(int i=0;i<r;i++)
	{
	  int tt,p,time;
	  string mess;
	  cin>>tt;
	  cin>>p;
	  cin>>time;
	  cin>>mess;
	  if(mess=="WRONG")
	    {
	      miss[p][tt]+=1;
	    }
	  else
	    {
	      d[tt-1].ans+=1;
	      d[tt-1].pen+=(miss[p][tt]*1200)+time;	      
	    }
	}
      sort(d.begin(),d.end(),comp);
      for(int i=0;i<d.size();i++)
	{
	  cout<<d[i].tid<<" "<<d[i].ans<<" "<<d[i].pen<<endl;
	}
	  

    }
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 10e9+9
#define EPS 1e-10
#define MAX_N 100100
#define MAX_M 100100

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int t, p, r;
int tid, pid, time;
string m;
P team[100];//????´???°???tid;first:correct,second:penalty
int inco[100][100];
vector< P > vp;
bool used[100];

bool flag(P p1, P p2){
	if (p1.first == p2.first)return p1.second < p2.second;
	return p1.first > p2.first;
}

int main(){
	while (cin >> t >> p >> r&&t + p + r){
		vp.clear();
		fill(used, used + 100,0);
		REP(i, 100)team[i] = P(0, 0);
		REP(i, 100)REP(j, 100)inco[i][j] = 0;
		REP(i, r){
			cin >> tid >> pid >> time >> m;
			if (m == "CORRECT"){
				team[tid].first++;
				team[tid].second += inco[tid][pid] * 1200 + time;
			}
			else{
				inco[tid][pid]++;
			}
		}
		FOR(i, 1, t + 1){
			vp.push_back(team[i]);
		}
		sort(ALL(vp), flag);
		REP(i, vp.size()){
			FOR(j, 1, t + 1){
				if (vp[i] == team[j] && !used[j]){
					cout << j << " " << vp[i].first
						<< " " << vp[i].second << endl;
					used[j] = 1;
				}
			}
		}
	}
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 10e9+9
#define EPS 1e-10
#define MAX_N 100100
#define MAX_M 100100

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int t, p, r;
int tid, pid, time;
string m;
P team[100];//????´???°???tid;first:correct,second:penalty
int inco[100][100];
vector<P> vp;
bool used[100];

bool flag(P p1, P p2){
	if (p1.first == p2.first)return p1.second < p2.second;
	return p1.first > p2.first;
}

int main(){
	while (cin >> t >> p >> r&&t + p + r){
		vp.clear();
		fill(used, used + 100,0);
		REP(i, 100)team[i] = P(0, 0);
		REP(i, 100)REP(j, 100)inco[i][j] = 0;
		REP(i, r){
			cin >> tid >> pid >> time >> m;
			if (m == "CORRECT"){
				team[tid].first++;
				team[tid].second += inco[tid][pid] * 1200 + time;
			}
			else{
				inco[tid][pid]++;
			}
			FOR(j, 1, t + 1){
				//cout << "!" << team[j].first << " " << team[j].second << endl;
			}
		}
		FOR(i, 1, t + 1){
			vp.push_back(team[i]);
		}
		sort(ALL(vp), flag);
		REP(i, vp.size()){
			FOR(j, 1, t + 1){
				if (vp[i] == team[j] && !used[j]){
					cout << j << " " << vp[i].first
						<< " " << vp[i].second << endl;
					used[j] = 1;
				}
			}
		}
	}
}