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 <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
typedef pair<ll, int> Pll;
int main()
{
  int T, P, R;
  while(cin >> T >> P >> R, T || P || R) {
    ll point[T+1], miss[T+1][P+1], pena[T+1];
    CLR(pena), CLR(miss), CLR(point);
    FOR(i,0,R) {
      int in[3]; FOR(j,0,3) cin >> in[j];
      string mes; cin >> mes;
      if(mes[0] == 'C') {
        point[in[0]]++;
        pena[in[0]] += miss[in[0]][in[1]] * 1200 + in[2];
      } else {
        miss[in[0]][in[1]]++;
      }
    }
    vector<Pll> sum_point(T);
    FOR(i,0,T) {
      ll p = point[i+1] * 100000000 - pena[i+1] * 100 - i;
      sum_point[i] = Pll(p, i + 1);
    }
    sort(sum_point.rbegin(), sum_point.rend());
    FOR(i,0,T) {
      int j = sum_point[i].second;
      cout << j << " " << point[j] << " " << pena[j] << endl;
    }
  }
  return 0;
}

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


using namespace std;
typedef pair<int, int> PII;
typedef pair<int, PII> PP; //score, penalty, teamID
static const int INF = 999999999;

void solve()
{
	int T,	P, R;
	while(cin >> T >> P >> R, T || P || R)
	{
		vector<PP> team_data(T);
		vector< vector<int> > wrong_data(T, vector<int>(P));
		for(int i = 0; i < T; ++i)
		{
			team_data[i].second.first = INF;
			team_data[i].second.second = INF - i;
		}
		for(int i = 0; i < R; ++i)
		{
			int tid, pid, time;
			string message;
			cin >> tid >> pid >> time;
			cin >> message;
			--tid;
			--pid;
			if(message == "CORRECT")
			{
				++team_data[tid].first;
				team_data[tid].second.first -= wrong_data[tid][pid] * 1200 + time;
			}
			else
			{
				++wrong_data[tid][pid];
			}
		}
		sort(team_data.begin(), team_data.end(), greater<PP>());
		for(int i = 0; i < T; ++i)
		{
			team_data[i].second.first = INF - team_data[i].second.first;
			team_data[i].second.second = INF - team_data[i].second.second;
		}
		for(int i = 0; i < T; ++i)
		{
			cout << team_data[i].second.second + 1 << " " << team_data[i].first << " " << team_data[i].second.first << endl;
		}
	}
}

int main()
{
	solve();
	return(0);
}

C++: #include <iostream>
#include <fstream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

#pragma comment(linker, "/STACK:400000000")

#define EPS 1e-9
#define INF MOD
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(it=X.begin();it!=X.end();it++)
#define iss istringstream
#define ite iterator
#define ll long long
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define pi pair<int,int>
#define pb push_back
#define sec second
#define sh(i) (1LL<<i)
#define sst stringstream
#define sz size()
#define vi vector<int>
#define vc vector
#define vl vector<ll>
#define vs vector<string>

int T,P,R,fail[55][11];

typedef pair<pi,int> tri;
tri t[55];

bool comp(tri a,tri b){
	return a.fir.fir > b.fir.fir
	|| a.fir.fir == b.fir.fir && a.fir.sec < b.fir.sec
	|| a.fir.fir == b.fir.fir && a.fir.sec == b.fir.sec && a.sec < b.sec;
}

int main(){
	while(cin>>T>>P>>R && T){
		rep(i,T)t[i]=mp(mp(0,0),i);
		memset(fail,0,sizeof(fail));
		rep(i,R){
			int tid,pid,time;
			string mes;
			cin>>tid>>pid>>time>>mes;
			if(mes[0]=='C'){
				t[tid-1].fir.fir++;
				t[tid-1].fir.sec+=fail[tid-1][pid-1]*1200+time;
			}else{
				fail[tid-1][pid-1]++;
			}
		}
		sort(t,t+T,comp);
		rep(i,T){
			cout<<t[i].sec+1<<" "<<t[i].fir.fir<<" "<<t[i].fir.sec<<endl;
		}
	}
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<cstring>
#include<cstdio>
#include<cmath>
using namespace std;

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

const int MAXT = 51, MAXP = 11;
int t, p ,r;

struct team
{
    int ac , pena , tid ;
    team(int ac, int pena, int tid):ac(ac), pena(pena), tid(tid){};
};

bool operator<(const team& t1,const team& t2)
{
    return (t1.ac > t2.ac || (t1.ac == t2.ac && t1.pena < t2.pena ) || (t1.ac == t2.ac && t1.pena == t2.pena && t1.tid < t2.tid));
};

int main()
{
    while(cin >> t >> p >> r && t)
    {
        vector<team> teams;
        rep(i,t) teams.push_back(team(0,0,i));

        int wa[MAXT][MAXP] = {};
        int tid, pid, time1;
        string s;
        
        REP(r)
        {
            cin >> tid >> pid >> time1 >> s;
            tid --; 
            if(s == "WRONG") wa[tid][pid]++;
            else {teams[tid].ac++; teams[tid].pena += wa[tid][pid] * 1200 + time1;}
        }

        sort(teams.begin(), teams.end() );
        REP(teams.size()) cout << teams[i].tid +1 << " "<< teams[i].ac << " " << teams[i].pena << endl;

    }
    return 0;
}