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 <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <map>
#include <set>
using namespace std;

#define rep(i,n) for(int i=0; i<n; i++)
#define FOR(i,s,n) for(int i=s; i<n; i++)
#define ALL(x) x.begin(), x.end()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;

struct Team {
	int id;
	int corr;
	ll pen;
};

bool operator<(const Team& lhs, const Team& rhs) {
	if( lhs.corr == rhs.corr ) {
		return lhs.pen < rhs.pen;
	}
	return lhs.corr > rhs.corr;
}

int main() {
	int T, P, R;
	while(cin >> T >> P >> R, T) {
		int wrong[51][11] = {};
		vector<Team> team(T);
		rep(i, T) {
			team[i].id = i+1;
		}
		rep(i, R) {
			int t, p, ti;
			string m;
			cin >> t >> p >> ti >> m;
			if( m == "CORRECT" ) {
				team[t-1].corr++;
				team[t-1].pen += 1200 * wrong[t][p] + ti;
			} else {
				wrong[t][p]++;
			}
		}
		sort( team.begin(), team.end() );
		rep(i, T) {
			cout << team[i].id << " " << team[i].corr << " " << team[i].pen << endl;
		}
	}
	return 0;
}

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

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<pii, int> ppi;

#define INF 1000000000

struct team{
  int id;
  int ac;
  int penalty;
  int wa[10];

  bool operator<(const team& r) const{
    if(ac == r.ac){
      if(penalty == r.penalty){
	return id < r.id;
      } else {
	return penalty < r.penalty;
      }
    } else {
      return ac > r.ac;
    }
  }
};

team teams[50];


int main(){
  int t,p,r;

  while(cin>>t>>p>>r, t|p|r){
    // initialize
    rep(i,t){
      teams[i].id=i+1;
      teams[i].ac=0;
      teams[i].penalty=0;
      rep(j,p){
	teams[i].wa[j]=0;
      }
    }

    // read records
    rep(i,r){
      int tid, pid, time;
      char m[10];
      scanf("%d %d %d %s", &tid, &pid, &time, m);
      tid--; pid--;
      if(m[0]=='C'){
	teams[tid].ac++;
	teams[tid].penalty += time + teams[tid].wa[pid]*1200;
      } else {
	teams[tid].wa[pid]++;
      }
    }

    sort(teams, teams+t);

    rep(i,t){
      printf("%d %d %d\n", teams[i].id, teams[i].ac, teams[i].penalty);
    }
  }
  return 0;
}

C++: # include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
# include <cstdlib>
# include <tuple>
# include <array>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2147483647;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr double HDINF = 50000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)      (x).begin(),(x).end()
# define UNIQUE(c)   sort(ALL((c)));(c).erase(unique(ALL((c))),(c).end())
# define LOWER(s)    transform(ALL((s)),(s).begin(),TL<char>)
# define UPPER(s)    transform(ALL((s)),(s).begin(),TU<char>)
# define FOR(i,a,b)  for(LL i=(a);i<(b);i++)
# define RFOR(i,a,b) for(LL i=(a);i>=(b);i--)
# define REP(i,n)    FOR(i,0,n)
# define INIT        std::ios::sync_with_stdio(false);std::cin.tie(0)

int t, p, r;
int points[100], pena[100], wacount[100][100];

int main() {
	while (cin >>t >> p >> r&&t&&p&&r) {
		REP(i, r) {
			int tid, pid, time;
			string mes;
			cin >> tid >> pid >> time >> mes;
			if (mes[0] == 'C') {
				points[tid]++;
				pena[tid] += wacount[tid][pid] * 1200 + time;
			}
			else {
				wacount[tid][pid]++;
			}
		}
		for (int q = 1; q <= t;q++) {
			int maxnum = -1, maxpos = -1, minpena = INF;
			for (int i = 1; i <= t;i++) {
				if (maxnum < points[i]) {
					maxnum = points[i];
					minpena = pena[i];
					maxpos = i;
				}
				else if (maxnum == points[i]) {
					if (minpena > pena[i]) {
						maxnum = points[i];
						minpena = pena[i];
						maxpos = i;
					}
				}
			}
			cout << maxpos << " " << points[maxpos] << " " << pena[maxpos] << endl;
			points[maxpos] = -INF;
			pena[maxpos] = INF;
		}
	}
}

C++: #include<bits/stdc++.h>
typedef struct ICPC
{
  int team;
  int ac;
  int wa;
  int p[10];
}icpc;

#define AC "CORRECT"
#define WA "WRONG"
using namespace std;
int main()
{
  while(1)
    {
      icpc ic[100]={};
      int t,p,r;
      int i;
      int a,b,d;
      char c[100];
      
      for(i=0;i<100;i++)
	ic[i].team=i+1;
      
      cin>>t>>p>>r;
      if(t==0)break;
      
      for(i=0;i<r;i++)
	{
	  cin>>a>>b>>d;
	  scanf("%s",c);
	  if(!strcmp(c,AC))
	    ic[a-1].ac++,ic[a-1].wa+=1200*ic[a-1].p[b]+d;
	  else
	    ic[a-1].p[b]++;
	}
      int j;
      icpc temp;
      for(i=0;i<t-1;i++)
	for(j=i+1;j<t;j++)
	  {
	    if(ic[i].ac<ic[j].ac)
	      {
		temp=ic[i];
		ic[i]=ic[j];
		ic[j]=temp;
	      }
	    else if(ic[i].ac==ic[j].ac)
	      {
		if(ic[i].wa>ic[j].wa)
		  {
		    temp=ic[i];
		    ic[i]=ic[j];
		    ic[j]=temp;
		  }
		else if(ic[i].wa==ic[j].wa)
		  if(ic[i].team>ic[j].team)
		    {
		      temp=ic[i];
		      ic[i]=ic[j];
		      ic[j]=temp;
		    }
	      }
	  }

	       
      for(i=0;i<t;i++)
	cout<<ic[i].team<<" "<<ic[i].ac<<" "<<ic[i].wa<<endl;
    }
}