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 <string>
#include <cstring>
#include <algorithm>

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

using namespace std;
typedef long long ll;

struct Team {
    int id,time,score;
    int p[100];

    void addscore() {
        score++;
    }

    bool operator<(const Team &t) const {
        if(score == t.score) {
            if(time == t.time)  {
                return id > t.id;
            }
            return time > t.time;
        }
        return score < t.score;
    }
};

int main() {
    int t,p,r;
    while(cin >> t >> p >> r) {
        if(t == 0 && p == 0 && r == 0) break;
        vector<Team> v;
        rep(i,t) {
            Team team;
            team.id = i;
            team.time = 0;
            team.score = 0;
            memset(team.p,0,sizeof(team.p));
            v.push_back(team);
        }

        rep(i,r) {
            int tid,pid,time;
            string mes;

            cin >> tid >> pid >> time >> mes;
            tid--;
            pid--;

            if(mes == "CORRECT") {
                v[tid].addscore();
                v[tid].time += 1200 * v[tid].p[pid] + time;
            }
            else {
                v[tid].p[pid]++;
            }
        }

        sort(v.begin(),v.end());
        rep(i,t) {
            cout << v[t-1-i].id+1 << " " << v[t-1-i].score << " " << v[t-1-i].time << endl;
        }

    }
    return 0;
}

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

#define rep2(i, b, n) for(int i=b; i < n; ++i)
#define rep(i, n) rep2(i, 0, n)

using namespace std;

struct team {
	int id;
	int time;
	int accept;
	int wrong[10];
};

bool operator<( team &a, team &b )
{
	if(a.accept > b.accept) return true;
	else if(a.accept < b.accept) return false;
	else {
		if(a.time < b.time) return true;
		else if(a.time > b.time) return false;
		else {
			if(a.id < b.id) return true;
			else return false;
		}
	}
	return false;
}

int main( void )
{
	int t, p, r;
	team T[50];
	while(cin >> t >> p >> r, t | p | r) {
		rep(i, t) {
			T[i].id = i+1;
			T[i].time = 0;
			T[i].accept = 0;
			rep(j, p) T[i].wrong[j] = 0;
		}
		rep(i, r) {
			int id, no, tm;
			string msg;
			cin >> id >> no >> tm >> msg;
			--id; --no;
			if(msg[0] == 'W')
				++T[id].wrong[no];
			else { // msg[0] == 'C'
				T[id].time += (tm + T[id].wrong[no]*1200);
				++T[id].accept;
			}
		}
		sort(T, T+t);
		rep(i, t)
			cout << T[i].id << ' ' << T[i].accept << ' ' << T[i].time << endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repp(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perr(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)

typedef long long LL;
typedef long double LD;

int main(){
  while(1){
    int t,p,r;
    cin >> t >> p >> r;
    if(t==0) return 0;
    vector<int> ac(t,0);
    vector<int> pn(t,0);
    vector<vector<int>> wa(t,vector<int>(p,0));
    int tid,pid,time;
    string ms;
    rep(i,r){
      cin >> tid >> pid >> time >> ms;
      tid--,pid--;
      if(wa[tid][pid]==-1) continue;
      if(ms=="CORRECT"){
        ac[tid]++;
        pn[tid]+=time+wa[tid][pid]*1200;
        wa[tid][pid]=-1;
      }else{
        wa[tid][pid]++;
      }
    }
    vector<int> jun(t,0);
    iota(all(jun),0);
    sort(all(jun),[&](const int &l, const int &r){
      return ac[l]==ac[r]?(pn[l]==pn[r]?l<r:pn[l]<pn[r]):ac[l]>ac[r];
    });
    rep(i,t){
      cout << jun[i]+1 SP ac[jun[i]] SP pn[jun[i]] << endl;
    }
  }
  return 0;
}

C++: #include <iostream>
#include <string>
#include <algorithm>
using namespace std;
typedef pair<int,pair<int,int> > P;

int t,p,r;

int main(){
  while(cin>>t>>p>>r,t){
    int an[t+1],wn[t+1][p+1],penalty[t+1];
    for(int i=1; i<=t; i++){
      for(int j=1; j<=p; j++)
	wn[i][j]=0;
      an[i]=penalty[i]=0;
    }
    for(int i=0; i<r; i++){
      int tid,pid,time;
      string mes;
      cin >> tid >> pid >> time >> mes;
      if(wn[tid][pid]==-1){
	;
      }if(mes=="CORRECT"){
	penalty[tid] += wn[tid][pid]*1200+time;
	an[tid]++;
	wn[tid][pid]=-1;
      }else{
	wn[tid][pid]++;
      }
    }
    
    P ps[t];
    for(int i=1; i<=t; i++)
      ps[i-1]=make_pair(-an[i],make_pair(penalty[i],i));
    sort(ps,ps+t);
    
    for(int i=0; i<t; i++)
      cout << ps[i].second.second << " " << -ps[i].first << " " << ps[i].second.first << endl;
  }
}