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

struct team_data {
    int id;
    int solved;
    int time;
    map<int, int> wrong;
};

int main() {
    int T, P, R;
    while(cin >> T >> P >> R, T) {
        vector<team_data> v(T);
        for(int i=0; i<T; ++i) {
            v[i].id = i+1;
        }

        for(int i=0; i<R; ++i) {
            int tID, pID, time;
            string message;
            cin >> tID >> pID >> time >> message;
            if(message == "CORRECT") {
                v[tID-1].time += time + v[tID-1].wrong[pID]*1200;
                v[tID-1].solved += 1;
            } else {
                v[tID-1].wrong[pID] += 1;
            }
        }

        stable_sort(v.begin(), v.end(), [](auto const& t1, auto const& t2) {
            if(t1.solved == t2.solved) {
                return t1.time < t2.time;
            } else {
                return t1.solved > t2.solved;
            }
        });

        for(auto& t : v) {
            cout << t.id << " " << t.solved << " " << t.time << endl;
        }
    }
}

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

// bad knowhow
#define REP(i,n) for(long long i=0;i<(long long)n;++i)

struct Score {
	Score() {}
	Score(int c, int p) : collects(c), penalty(p) {}
	bool operator<(const Score & other) const {
		if (collects == other.collects){
			if (penalty == other.penalty) return id < other.id;
			return penalty < other.penalty;
		}
		return collects > other.collects;
	}
	int collects;
	long long penalty;
	int id;
};

int wrong[50][10];
bool collect[50][10];
Score score[50];


int main() {
	while (true) {
		fill(score, score + 50, Score(0,0));
		fill(*collect, *collect + 500, false);
		fill(*wrong, *wrong + 500, 0);

		int t, p, r;
		cin >> t >> p >> r;
		if (t == 0) break;

		REP(i, t) score[i].id = i;

		REP(i, r) {
			int tid, pid, time;
			string message;
			cin >> tid >> pid >> time >> message;
			tid--; pid--;
			if (collect[tid][pid]) continue;
			if (message == "CORRECT") {
				score[tid].collects++;
				collect[tid][pid] = true;
				score[tid].penalty += wrong[tid][pid] * 1200 + time;
			} else {
				wrong[tid][pid]++;
			}
		}

		sort(score, score+t);
		REP(i, t) {
			cout << score[i].id + 1 << " " << score[i].collects << " " << score[i].penalty << 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;
      if(t==0)
	exit(0);
      cin>>p;
      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};
      cin>>r;
      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 <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
  int T, P, R, tid, pid, t;
  string m;
  while (cin >> T >> P >> R, T) {
    vector< vector<int> > V(T, vector<int>(3, 0));
    vector< vector<int> > Problem(T, vector<int>(P, 0));
    for (int i = 0; i < T; ++i) V[i][2] = i+1;
    for (int i = 0; i < R; ++i) {
      cin >> tid >> pid >> t >> m;
      --tid;
      --pid;
      if (Problem[tid][pid] != 1) {
	if (m == "CORRECT") {
	  V[tid][1] += -Problem[tid][pid]*1200 + t;
	  Problem[tid][pid] = 1;
	  --V[tid][0];
	} else {
	  --Problem[tid][pid];
	}
      }
    }
    sort(V.begin(), V.end());
    for (int i = 0; i < T; ++i) {
      cout << V[i][2] << " " << -V[i][0] << " " << V[i][1] << endl;

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

//define
#define ALL(a) a.begin(),a.end()
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define debug(x) if(1) cout<<#x<<":"<<x<<endl;
#define DEBUG(x) if(1) cout<<#x<<":"<<x<<endl;
#define ll long long

//constant
const int MOD=1000000007;
const int INF=INT_MAX/3-1;
const double EPS=1e-9;
const int dx[]={1,0,-1,0};
const int dy[]={0,1,0,-1};

//typedef
typedef vector<int> vi;
typedef vector<vector<int>> vvi;






int main(){
    int t,r,p;
    while(cin>>t>>p>>r,t){
        vvi team(t,vi(p,0));
        vector<tuple<int,int,int>> tem(t,make_tuple(0,0,0));
        REP(i,t)
            get<0>(tem[i])=i+1;
        REP(i,r){
            int tid,pid,time;
            string mes;
            cin>>tid>>pid>>time>>mes;
            tid--,pid--;

            if(mes=="CORRECT"){
                get<1>(tem[tid])++;
                get<2>(tem[tid])+=time+team[tid][pid]*1200;


            }
            if(mes=="WRONG")
                team[tid][pid]++;



        }
        REP(i,t)
            get<0>(tem[i]);
        sort(ALL(tem),
        [](tuple<int,int,int> lef,tuple<int,int,int> rig)
{return (get<1>(lef)>get<1>(rig)
        || get<1>(lef)==get<1>(rig) && get<2>(lef)<get<2>(rig)
        || get<1>(lef)==get<1>(rig) && get<2>(lef)==get<2>(rig) && get<0>(lef)<get<0>(rig));});

        for(int i=0;i<t;i++)
            cout<<get<0>(tem[i])<<" "<<get<1>(tem[i])<<" "<<get<2>(tem[i])<<endl;

    }

    return 0;
}