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;

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();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#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 range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

struct team{
	int a,t,n;
	bool operator<(const team &arg)const{
		if(a==arg.a&&t==arg.t) return n<arg.n;
		if(a==arg.a) return t<arg.t;
		return a>arg.a;
	}
};

team info[55];

int wrong[55][11];

int main(void){
	int t,p,r;
	while(cin >> t >> p >> r){
		if(t==0)
			break;
		rep(i,55)rep(j,11) wrong[i][j]=0;
		rep(i,55) info[i].a=info[i].t=0,info[i].n=i+1;
		rep(i,r){
			int tid,pid,times;
			cin >> tid >> pid >> times;
			string m;
			cin >> m;
			if(wrong[tid][pid]!=-1){
				if(m=="CORRECT"){
					info[tid-1].a++;
					info[tid-1].t+=(times+1200*wrong[tid][pid]);
					wrong[tid][pid]=-1;
				}else
					wrong[tid][pid]++;
			}
		}
		sort(info,info+t);
		rep(i,t) cout << info[i].n << " " << info[i].a << " " << info[i].t << endl;
	}
	return 0;
}

C++: // clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef vector<vpii> vvpii;
const int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
const int MOD = 1000000007;
const double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

struct ProbState {
  bool uresii = false;
  int kanasii = 0;
  int penalty;

  ProbState() {
  }
};

struct Team {
  vector<ProbState> states;
  int id;
  int solved  = 0;
  int penalty = 0;

  Team(int probs, int id)
    : states(probs), id(id) {
  }
};

bool operator<(const Team &a, const Team &b) {
  if (a.solved != b.solved) return a.solved > b.solved;
  return a.penalty < b.penalty;
}

void solve() {
  int t, p, r;
  while (cin >> t >> p >> r, t) {
    vector<Team> ts;
    ts.reserve(t);
    rep(i, t) ts.emplace_back(p, i + 1);
    while (r--) {
      int tid, pid, tm;
      string msg;
      cin >> tid >> pid >> tm >> msg;
      --tid, --pid;
      if (ts[tid].states[pid].uresii) continue;
      if (msg == "CORRECT") {
        ts[tid].states[pid].uresii = true;
        ts[tid].solved++;
        ts[tid].states[pid].penalty = ts[tid].states[pid].kanasii * 1200 + tm;
        ts[tid].penalty += ts[tid].states[pid].penalty;
      }
      if (msg == "WRONG") ts[tid].states[pid].kanasii++;
    }
    stable_sort(all(ts));
    for (Team x : ts) cout << x.id << ' ' << x.solved << ' ' << x.penalty << endl;
  }
}

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

using namespace std;

struct Team {
	int tid, correct, penalty;

	Team() {}
	Team(int tid, int correct, int penalty) : tid(tid), correct(correct), penalty(penalty) {}
};
bool operator >(const Team& t1, const Team& t2) {
	if (t1.correct == t2.correct) return t1.penalty < t2.penalty;
	else return t1.correct > t2.correct;
}

int main() {
	int T, P, R;
	while ( cin >> T >> P >> R, T || P || R ) {
		int correct[50] = {0}, wrong[50][10] = {0};
		bool solver[50][10] = {0};
		int penalty[50] = {0};
		for (int i = 0; i < R; ++i) {
			int tid, pid, time; string message; cin >> tid >> pid >> time >> message;
			--tid, --pid;
			if (message == "CORRECT") {
				if (!solved[tid][pid]) {
					++correct[tid];
					penalty[tid] += wrong[tid][pid] * 1200 + time;
					solved[tid][pid] = true;
				}
			}
			else {
				++wrong[tid][pid];
			}
		}

		vector<Team> v(T);
		for (int i = 0; i < T; ++i) {
			v[i] = Team(i+1, correct[i], penalty[i]);
		}
		sort( v.begin(), v.end(), greater<Team>() );

		for (int i = 0; i < T; ++i) {
			cout << v[i].tid << " " << v[i].correct << " " << v[i].penalty << endl;
		}
	}
}