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

// B

int penalty[55], accept[55];
int wrong[55][55];

int main(){
    int T,P,R,i;
    int tID, pID, time;
    string msg;
    

    while( cin >> T >> P >> R, T|P|R ){

        memset(accept, 0, sizeof(accept));
        memset(wrong, 0, sizeof(wrong));
        memset(penalty, 0, sizeof(penalty));

        for(i=0; i<R; i++){
            cin >> tID >> pID >> time >> msg;
            if( wrong[tID][pID] >= 0 ){
                if( msg == "CORRECT" ){
                    penalty[tID] += wrong[tID][pID] * 1200 + time;
                    wrong[tID][pID] = -1;
                    accept[tID]++;
                }
                else{
                    wrong[tID][pID]++;
                }
            }
        }

        vector<pair<int, pair<int,int> > > v;
        for(i=1; i<=T; i++){
            v.push_back(make_pair(-accept[i], make_pair(penalty[i], i)));
        }

        sort(v.begin(), v.end());
        for(i=0; i<v.size(); i++){
            cout << v[i].second.second << " " << -v[i].first << " " << v[i].second.first << endl;
        }
    }

    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
struct S{
  int id,a=0,p=0,w[11]={};
  bool operator<(const S&o)const{
    return a==o.a?p==o.p?id<o.id:p<o.p:a>o.a;
  }
};
int t,p,r,i,a,b,c;
string s;
main(){
  while(cin>>t>>p>>r,t){
    S z[t];
    for(i=0;i<t;++i)z[i].id=i+1;
    for(i=0;i<r;++i){
      cin>>a>>b>>c>>s;
      if(s=="CORRECT")z[--a].a++,z[a].p+=z[a].w[b]*1200+c;
      else z[--a].w[b]++;
    }
    sort(z,z+t);
    for(i=0;i<t;++i)cout<<z[i].id<<' '<<z[i].a<<' '<<z[i].p<<endl;
  }
}

C++: #include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#define F first
#define S second
using namespace std;
int t,p,r;
pair<int,pair<int,int> > s[55];
int w[55][11];
int main(void){
  while(cin >> t >> p >> r && t){
    for(int i = 0; i < t; i++){
      s[i].F = s[i].S.F = 0;
      s[i].S.S = i+1;
    }
    memset(w,0,sizeof(w));
    for(int i = 0; i < r; i++){
      int a,b,ti;
      string m;
      cin >> a >> b >> ti >> m;
      if(m == "WRONG"){
	w[a][b]++;
      }else{
	s[a-1].F--;
	s[a-1].S.F += w[a][b]*1200+ti;
      }
    }
    sort(s,s+t);
    for(int i = 0; i < t; i++){
      cout << s[i].S.S << " " << -s[i].F << " " << s[i].S.F << endl;
    }
  }
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;

struct team{
  int tid;
  int pen;
  int ans;
};


bool comp (const struct team x1,const struct team x2)
{
  if(x1.ans>x2.ans)
    return true;
  else if(x1.ans<x2.ans)
    return false;
  else
    {
      if(x1.pen<x2.pen)
	return true;
      else if(x1.pen>x2.pen)
	return false;
      else
	{
	  if(x1.tid<x2.tid)
	    return true;
	  else if(x1.tid>x2.tid)
	    return false;
	}
      
    }
}


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

      vector<team> d;
      for(int i=0;i<p;i++)
	{
	  struct team x;
	  x.tid=i+1;
	  x.pen=0;
	  x.ans=0;
	  d.push_back(x);
	}
      int miss[11][51]={0};

      for(int i=0;i<r;i++)
	{
	  int t,p,time;
	  string mess;
	  cin>>t;
	  cin>>p;
	  cin>>time;
	  cin>>mess;
	  if(mess=="WRONG")
	    {
	      miss[p][t]+=1;
	    }
	  else
	    {
	      d[t-1].ans+=1;
	      d[t-1].pen+=(miss[p][t]*1200)+time;	      
	    }
	}
      sort(d.begin(),d.end(),comp);
      for(int i=0;i<d.size();i++)
	{
	  printf("%d %d %d\n",d[i].tid,d[i].ans,d[i].pen);
	}	  
	  

    }
}

C++: #include<iostream>
#include<cstdio>
#include<algorithm>
#include<map>
#include<vector>
#define F first
#define S second
using namespace std;
typedef pair<int,int> Po; //Po(tID,pID)
typedef pair<Po,int> PP; //PP(Po(ID,solved),time)

bool cmp(const PP &p,const PP &q){
  if(p.F.S != q.F.S)return p.F.S > q.F.S;
  if(p.S != q.S)return p.S < q.S;
  return p.F.F < q.F.F;
}


int main(){
  int T,P,R,tID,pID,time;
  string message;

  while(true){
    scanf("%d%d%d",&T,&P,&R);
    if(T+P+R == 0)break;
    vector<PP> total;
    for(int i=0;i<T;i++)total.push_back(PP(Po(i+1,0),0));
    map<Po,int> info;
    for(int i=0;i<R;i++){
      scanf("%d %d %d",&tID,&pID,&time);
      tID--;
      cin >> message;
      if(message[0] == 'W'){
	info[Po(tID,pID)]++;
      }
      else {
	total[tID].S+=+info[Po(tID,pID)]*1200+time;
	total[tID].F.S+=1;
      }
    }

    sort(total.begin(),total.end(),cmp);
  
    for(int i=0;i<total.size();i++){
      printf("%d %d %d\n",total[i].F.F,total[i].F.S,total[i].S);
    }  

  
  }
  return 0;
}