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<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define rp(a) while(a--)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	int T,P,R;
	while(cin>>T>>P>>R,T+P+R){
		int miss[51][11]={0};
		int pe[51]={0};
		int co[51]={0};
		bool h[51][11]={false};
		rep(i,R){
			int a,b,c;
			string s;
			cin>>a>>b>>c>>s;
			a--;b--;
			if(h[a][b])continue;
			if(s=="CORRECT"){
				pe[a]+=miss[a][b]*1200+c;
				co[a]++;
				h[a][b]=true;
			}else miss[a][b]++;
		}
		int out[51];
		rep(i,51)out[i]=i;
		loop(i,1,T)for(int j=T-1;j>=i;j--){
			if(co[out[j-1]]<co[out[j]])swap(out[j],out[j-1]);
			else if(co[out[j-1]]==co[out[j]]&&pe[out[j-1]]>pe[out[j]])swap(out[j],out[j-1]);
			else if(co[out[j-1]]==co[out[j]]&&
					pe[out[j-1]]==pe[out[j]]&&
					out[j-1]>out[j])swap(out[j],out[j-1]);
		}
		rep(i,T)cout<<out[i]+1<<" "<<co[out[i]]<<" "<<pe[out[i]]<<endl;
	}
}

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>

#define INF 999999999
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define MOD(x) (x%(mod))
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

/*---------------------------------------------------*/

void judge_sort(pair<pi,int>score[],int t){
  //sort(score,score+t);reverse(score,score+t);
  rep(j,t)rep(i,t-1){
    //cout<<"DEBUG "<<score[i].first.second<<" "<<score[i+1].first.second<<endl;
    if((score[i].first.first < score[i+1].first.first)||
			(score[i].first.first == score[i+1].first.first && score[i].first.second > score[i+1].first.second)||
                        (score[i].first.first == score[i+1].first.first && score[i].first.second == score[i+1].first.second&&score[i].second > score[i+1].second)){
                               swap(score[i].first.first,score[i+1].first.first);
                               swap(score[i].first.second,score[i+1].first.second);
                               swap(score[i].second,score[i+1].second);
    }
  }
}

int main(){
  pair<pi,int>score[55];
  int wa[55][12];
  string s;
  int t,p,r,tID,pID,time;
  
  while(cin>>t>>p>>r){
    if(t==0&&p==0&&r==0)break;

    rep(i,55){
      score[i].second=i+1;
      score[i].first.first=0;
      score[i].first.second=0;
      rep(j,12){
	wa[i][j]=0;
      }
    }
    
    rep(i,r){
      cin>>tID>>pID>>time>>s;
      
      if(s=="CORRECT"&&wa[tID-1][pID]!=-1){
	score[tID-1].first.first+=1;
	cout<<"tID: "<<tID<<" <-- "<<time<<" * "<<wa[tID-1][pID]<<" * 1200"<<endl;
	score[tID-1].first.second+=(time+wa[tID-1][pID]*1200);
	wa[tID-1][pID]=-1;
      }else if(s=="WRONG"){
	wa[tID-1][pID]++;
      }
      
    }
    judge_sort(score,t);
    
    rep(i,t)cout<<score[i].second<<" "<<score[i].first.first<<" "<<score[i].first.second<<endl;
    //cout<<endl;
  }
  return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <iomanip>

#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>

#include <numeric>
#include <algorithm>
#include <functional>

#include <cctype>

#include <complex>
#include <string>
#include <sstream>

using namespace std;

#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define rep(i,n) for(unsigned int i=0;i<(n);i++)
#define tr(it,container) for(typeof(container.begin()) it = container.begin(); \
                                                  it != container.end(); ++it)
#define mp(a,b) make_pair((a),(b))

typedef long long ll;
typedef complex<double> P;
const int dx[] = {1,0,-1,0};
const int dy[] = {0,-1,0,1};
const double EPS = 1e-9;
const int days[] = {31,28,31,30,31,30,31,31,30,31,30,31};
const int daysleap[] = {31,29,31,30,31,30,31,31,30,31,30,31};

bool sorter(pair<pair<int,int>,int> a,pair<pair<int,int>,int> b){
    // solved
    if(a.first.first > b.first.first){
        return true;
    }else if(a.first.first == b.first.first){
        //time
        if(a.first.second < b.first.second){
            return true;
        }else if(a.first.second == b.first.second){
            return a.second < b.second;
        }else{
            return false;
        }
    }else{
        return false;
    }
}
int main(){
    while(true){
        int T,P,R;
        cin >> T >> P >> R;
        if(T==0) break;
        // solved , time , id
        vector<pair<pair<int,int>,int> > S(T);
        rep(i,T) S[i].second = i+1;
        // pena
        vector<vector<int> > PE(T,vector<int>(P));
        rep(i,R){
            int tID,pID,time;string message;
            cin >> tID >> pID >> time >> message;
            tID--;pID--;
            if(message == "CORRECT"){
                S[tID].first.first += 1;
                S[tID].first.second += PE[tID][pID]*1200 + time;
            }else{
                PE[tID][pID]++;
            }
        }
        sort(all(S),sorter);
        rep(i,T){
            cout << S[i].second << " " << S[i].first.first << " " << S[i].first.second << endl;
        }
    }
    return 0;
}