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 <algorithm>
#include <array>
#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

struct team_t {
  array<uint32_t, 11> wrongs;
  uint64_t penalty;
  uint32_t corrects;
  uint32_t id;
  team_t() : wrongs({}), penalty(0), corrects(0), id(0) {}

  void correct(uint32_t pid, uint32_t time) {
    corrects++;
    penalty += 1200 * wrongs[pid] + time;
  }

  void wrong(uint32_t pid) { wrongs[pid]++; }

  void println() { cout << id << " " << corrects << " " << penalty << endl; }

  bool operator<(const team_t &team) const {
    return corrects == team.corrects ? penalty < team.penalty
                                     : corrects > team.corrects;
  }
};

int32_t main() {
  while (true) {
    uint32_t T, P, R;
    cin >> T >> P >> R;
    if (T == 0) break;

    vector<team_t> teams(T + 1);
    for (uint32_t i = 1; i <= T; i++) {
      teams[i].id = i;
    }

    for (uint32_t i = 0; i < R; i++) {
      uint32_t tid, pid, t;
      string msg;
      cin >> tid >> pid >> t >> msg;
      if (msg == "WRONG") {
        teams[tid].wrong(pid);
      } else if (msg == "CORRECT") {
        teams[tid].correct(pid, t);
      }
    }

    sort(teams.begin() + 1, teams.begin() + T + 1);

    for (uint32_t i = 1; i <= T; i++) {
      teams[i].println();
    }
  }

  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;


signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    int T, P, R;
    while (cin >> T >> P >> R, T) {
        VV v(T, V(3, 0));   // AC, pena, id(0-index)
        rep(i, T) v[i][2] = i;

        VV wa(T, V(P, 0));
        while (R--) {
            int tid, pid, t;
            string m;
            cin >> tid >> pid >> t >> m;
            tid--; pid--;
            if (m[0] == 'C') {
                v[tid][0]++;
                v[tid][1] += wa[tid][pid] * 1200 + t;
            } else {
                wa[tid][pid]++;
            }
        }

        rep(i, T) v[i][0] *= -1;
        sort(all(v));
        rep(i, T) v[i][0] *= -1;

        for (auto u : v) {
            cout << u[2] + 1 << " " << u[0] << " " << u[1] << endl;
        }

    }
}

C++: #include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#define INF (2000000000)
#define MAX (2000)
using namespace std;

typedef vector<int> VI;
typedef vector<int>::iterator VII;
typedef vector<double> VD;
typedef vector<double>::iterator VDI;


typedef struct
{
	int id;
	int ac;
	int wa[10];
	int pe;
} TEAM;
TEAM team[50];

bool cmp(TEAM A, TEAM B)
{
	if (A.ac == B.ac){
		if (A.pe == B.pe){
			return (A.id < B.id);
		}
		return (A.pe < B.pe);
	}
	return (A.ac > B.ac);
}

int main()
{
	int T, P, R;
	while (scanf(" %d %d %d", &T, &P, &R), T + P + R){
		memset(team, 0, sizeof(team));
		for (int i = 0; i < T; i++){
			team[i].id = i + 1;
		}
		
		for (int i = 0; i < R; i++){
			int tID, pID, time;
			char mes[16];
			
			scanf("%d %d %d", &tID, &pID, &time);
			tID--; pID--;
			scanf("%s", mes);
			
			if (!strcmp(mes, "CORRECT")){
				team[tID].ac++;
				team[tID].pe += team[tID].wa[pID] * 1200 + time;
			}
			else {
				team[tID].wa[pID]++;
			}
		}
		
		sort(team, team + T, cmp);
		
		for (int i = 0; i < T; i++){
			printf("%d %d %d\n", team[i].id, team[i].ac, team[i].pe);
		}
	}
	
	return 0;
}

C++: #include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
//C++11
#if __cplusplus == 201103L
#include <tuple>
#endif

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
struct Tm{
  int t, a, p; //team, ac, pena
  Tm(int t, int a, int p) :
    t(t), a(a), p(p) {}
  bool operator < (const Tm& r) const {
    return a != r.a ? a > r.a : p != r.p ? p < r.p : t < r.t;
  }
};

int main(){
  int T, P, R;
  while(cin>>T>>P>>R && T){
    int wrong[100][100] = {};
    int ac[100] = {};
    int pena[100] = {};
    REP(iter, R){
      int t, p, time;
      string mes;
      cin>>t>>p>>time>>mes;
      t--; p--;
      if(mes == "WRONG"){
        wrong[t][p] += 1;
      }else{
        pena[t] += 1200 * wrong[t][p] + time;
        ac[t] += 1;
      }
    }
    vector<Tm> team;
    REP(i, T){
      team.push_back(Tm(i+1, ac[i], pena[i]));
    }
    sort(team.begin(), team.end());
    REP(i, T){
      Tm t = team[i];
      printf("%d %d %d\n",t.t, t.a, t.p);
    }
  }
  return 0;
}