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++: #define  _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
#pragma comment (linker, "/STACK:526000000")

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(10);
}

#define int ll
void solve() {
	while (true) {
		int t, p, r;
		cin >> t >> p >> r;
		if (t == 0) return;
		map<int, pair<int, int>> teaminfo;
		map<pair<int, int>, int> penalty;
		REP(i, r) {
			int a, b, c;
			string d;
			cin >> a >> b >> c >> d;
			if (d == "CORRECT") {
				int hoge = c + penalty[mp(a, b)] * 1200;
				teaminfo[a].first++;
				teaminfo[a].second += hoge;
			}
			else {
				penalty[mp(a, b)]++;
			}
		}
		vector<tuple<int, int, int>> teams;
		for (int i = 1; i <= t; ++i) {
			teams.push_back(make_tuple(teaminfo[i].first, -teaminfo[i].second, -i));
		}
		sort(ALL(teams));
		reverse(ALL(teams));
		REP(i, teams.size()) {
			cout << -get<2>(teams[i]) << " " << get<0>(teams[i]) << " " << -get<1>(teams[i]) << endl;
		}
	}
}
#undef int

int main() {
	init();
	solve();
}

C++: #include <iostream>
#include <vector>
#include <set>
#include <string>
#include <string.h>
#include <algorithm>


#define C "CORRECT"
#define W "WRONG"

#define T_MAX 51
#define P_MAX 11

struct TeamData
{
	int teamID;
	int ok;
	int kasan;
};

bool operator < (const TeamData& self,const TeamData& oth){  
    if(self.ok==oth.ok)return self.kasan<oth.kasan;  
    return self.ok>oth.ok;
}

using namespace std;

int main(void)
{
	int t,p,r;
	int i1,i2;
	int tID,pID,tim;
	string s;

	int miss[T_MAX][P_MAX];


	while(1){
		cin >> t >> p >> r;
		if(t+p+r==0) break;

		vector<TeamData> team(t);
		memset(miss,0,sizeof(miss));
		

		for(i1=0;i1<t;i1++){
			team[i1].teamID=i1+1;
			team[i1].ok=0;
			team[i1].kasan=0;
		}


		for(i1=0;i1<r;i1++){
			cin >> tID >> pID >> tim >> s;

			if (s==C) {
				team[tID-1].ok++;
				team[tID-1].kasan+=miss[tID][pID]*1200+tim;
			}
			else if(s==W) {
				miss[tID][pID]++;
			}
		}

		sort(team.begin(), team.end());

		for(i1=0;i1<t;i1++){
			cout << team[i1].teamID << " " << team[i1].ok << " " << team[i1].kasan << endl;
		}
	}
	return 0;

}

C++: #include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;

class C{
  public:
    int num, ac, time;
    vector<int> wa;
    C(int p, int n){
      num = n;
      ac = 0;
      time = 0;
      wa = vector<int>(p, 0);
    }
    C(){}
    bool operator < (const C &c) const {
      if(ac != c.ac) return ac > c.ac;
      return time < c.time;
    }
};

int main() {
  int T, P, R;
  while(cin >>T >>P >>R && T){
    vector<C> teams(T);
    REP(i, T) teams[i] = C(P, 1 + i);
    REP(i, R){

      int t, p, time;
      string s;
      cin >>t >>p >>time >>s;
      --t; --p;
      if(s == "CORRECT"){
        ++teams[t].ac;
        teams[t].time += 1200 * teams[t].wa[p] + time;
      } else ++teams[t].wa[p];
    }
    SORT(teams);
    REP(i, T) cout <<teams[i].num <<" " <<teams[i].ac <<" " <<teams[i].time <<endl;
  }
  return 0;
}

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

int main(void){
  while(true){
    int t, p, r;
    cin >> t >> p >> r;
    if(t == 0 && p == 0 && r == 0){ break; }

    vector<vector<int> > wa(t, vector<int>(p, 0));
    vector<pair<pair<int, int>, int> > penalty;
    for(int i = 0; i < t; i++)
      penalty.push_back(make_pair(make_pair(0, 0), i));

    int tID, pID, time;
    string message;
    for(int i = 0; i < r; i++){
      cin >> tID >> pID >> time >> message;
      --tID;
      --pID;
      if(wa[tID][pID] < 0){ continue; }
      if(message == "CORRECT"){
        --penalty[tID].first.first;
        penalty[tID].first.second += wa[tID][pID] * 1200 + time;
        wa[tID][pID] = -1;
      }
      else{ ++wa[tID][pID]; }
    }
    sort(penalty.begin(), penalty.end());

    for(int i = 0; i < t; i++){
      printf("%d %d %d\n", penalty[i].second + 1, -penalty[i].first.first, penalty[i].first.second);
    }
  }

  return 0;
}