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 <vector>
#include <set>
#include <string>
#include <string.h>
#include <algorithm>


#define C "CORRECT"
#define W "WRONG"

#define T_MAX 55
#define P_MAX 15

struct TeamData
{
	int teamID;
	int ok;
	int kasan;
};

bool operator < (const TeamData& self,const TeamData& oth){  
    if(self.ok==oth.ok) {
    	if(self.kasan==oth.kasan) return self.teamID<oth.teamID;
    	return self.kasan<oth.kasan;
    }  
    return self.ok>oth.ok;
}

using namespace std;

int main(void)
{
	int t,p,r;
	int i1,i2;
	int tID,pID,tim;
	string s;

	int miss[T_MAX][P_MAX];


	while(1){
		cin >> t >> p >> r;
		if(t+p+r==0) break;

		vector<TeamData> team(t);
		memset(miss,0,sizeof(miss));
		

		for(i1=0;i1<t;i1++){
			team[i1].teamID=i1+1;
			team[i1].ok=0;
			team[i1].kasan=0;
		}


		for(i1=0;i1<r;i1++){
			cin >> tID >> pID >> tim >> s;

			if (s==C) {
				team[tID-1].ok++;
				team[tID-1].kasan+=(miss[tID][pID]*1200+tim);
				
			}
			else if(s==W) {
				miss[tID][pID]++;
			}
		}

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

		for(i1=0;i1<t;i1++){
			cout << team[i1].teamID << " " << team[i1].ok << " " << team[i1].kasan << endl;
		}
	}
	return 0;

}

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

using namespace std;

int main() {
	int T, P, R;
	while (cin >> T >> P >> R) {
		if (T == 0 && P == 0 && R == 0) {
			break;
		}
		int team[50][10] = {0};
		int pena[50][2] = {0};
		for (int i = 0; i < R; i++) {
			int tid, pid, time;
			string message;
			cin >> tid >> pid >> time >> message;
			if (message == "CORRECT") {
				pena[tid-1][0]++;
				pena[tid-1][1] += team[tid-1][pid-1] * 1200 + time;
			} else {
				team[tid-1][pid-1]++;
			}
		}
		int juni[50];
		for (int i = 0; i < T; i++) {
			juni[i] = i+1;
		}
		for (int i = 0; i < T; i++) {
			for (int j = T-1; j > i; j--) {
				if (pena[j][0] > pena[j-1][0]) {
					swap(pena[j][0], pena[j-1][0]);
					swap(pena[j][1], pena[j-1][1]);
					swap(juni[j], juni[j-1]);
				} else if (pena[j][0] == pena[j-1][0]) {
					if (pena[j][1] < pena[j-1][1]) {
						swap(pena[j][0], pena[j-1][0]);
						swap(pena[j][1], pena[j-1][1]);
						swap(juni[j], juni[j-1]);
					}
				} 
			}
		}
		for (int i = 0; i < T; i++) {
			cout << juni[i] << ' ' << pena[i][0] << ' ' << pena[i][1] << endl;
		}
	}
	return 0;
}

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

struct Team{
  int team_num,time,correct;
};

int main(){
  Team data[51];
  while(1){
    int i,j,T,P,R; cin >> T >> P >> R;
    if ( T == 0 && P == 0 && R == 0 ) break;
    for( i = 1; i <= T; i++ ){
      data[i].time = 0;
      data[i].correct = 0;
      data[i].team_num = i;
    }

    int t,p,jikan,twrong[51][11];
    for( i = 0; i < 51; i++ ){
      for( j = 0; j < 11; j++ ){
	twrong[i][j]=0;
      }
    }
    string str;
    for( i = 0; i < R; i++ ){
      cin >> t >> p >> jikan >> str;
      if( str == "CORRECT" ){
	data[t].correct++;
	data[t].time = data[t].time + twrong[t][p] * 1200 + jikan;
      }else if( str == "WRONG" ){
	twrong[t][p]++;
      }
    }
    for( i = 0; i < T; i++ ){
      for( j = 1; j < T; j++ ){
	if( data[j].team_num > data[j+1].team_num ) 
	  swap( data[j],data[j+1] );
      }
    }

    for( i = 0; i < T; i++ ){
      for( j = 1; j < T; j++ ){
	if( data[j].time > data[j+1].time ) 
	  swap( data[j],data[j+1] );
      }
    }

    for( i = 0; i < T; i++ ){
      for( j = 1; j < T; j++ ){
	if( data[j].correct < data[j+1].correct ) 
	  swap( data[j],data[j+1] );
      }
    }

    for( i = 1; i <= T; i++ ){
      cout << data[i].team_num << " "
	   << data[i].correct << " " << data[i].time << endl;
    }
    
  }
  return 0j;
}

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

using TeamInfo =  struct TeamInfo
{
    int tID;
    int points;
    int pena;
    int ProbMiss[10];

    TeamInfo(int tid) : tID(tid) {}
};

bool cmp(const TeamInfo &a, const TeamInfo &b)
{
    return (a.points == b.points)?(a.pena == b.pena? a.tID < b.tID:a.pena < b.pena):(a.points > b.points);
}

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

        vector<TeamInfo> v;

        for (size_t i = 0; i < t; i++)
        {
            v.push_back(TeamInfo(i+1));
        }

        for (size_t i = 0; i < r; i++)
        {
            int tID, pID, tim;
            string mess;
            cin >> tID >> pID >> tim >> mess;

            if (mess == "CORRECT")
            {
                v[tID - 1].points += 1;
                v[tID - 1].pena += ((v[tID - 1].ProbMiss[pID - 1]) * 1200) + tim;
            }
            if (mess == "WRONG")
            {
                v[tID - 1].ProbMiss[pID - 1] += 1;
            }
        }
        sort(v.begin(), v.end(), cmp);
        for (size_t i = 0; i < t; i++)
        {
            cout << v[i].tID <<" "<< v[i].points <<" "<< v[i].pena << endl;
        }
    }
    return 0;
}

C++: #include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
//cin.sync_with_stdio(false);
//streambuf
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
using vi = vector<int>;
using vpii = vector<pii>;
template<class T, class T2> using umap = unordered_map<T, T2>;
template<class T> using uset = unordered_set<T>;
#define ALL(a) a.begin(),a.end()
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a) for(int i=1;i<=a;i++)
int main() {
	int t, p, r;
	while (cin >> t >> p >> r, t) {
		vector<tuple<int, int, int, vi>> buf(t, make_tuple(0, 0, 0, vi(p + 1)));//-ac,pena,team
		rep(i, t) {
			get<2>(buf[i]) = i + 1;
		}
		rep(j, r) {
			int t, p, time;
			string mes;
			cin >> t >> p >> time >> mes;
			t--;
			get<3>(buf[t])[p] +=(mes[0]=='W'?1200:time);
			if (mes[0] == 'C') {
				get<0>(buf[t])--;
				get<1>(buf[t]) += get<3>(buf[t])[p];
			}
		}
		sort(ALL(buf));
		for (auto &a : buf) {
			cout << get<2>(a) <<' '<< -get<0>(a) <<' '<< get<1>(a) << endl;
		}
	}
}