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 <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

int main(){
    int team_num, prob_num, R;
    while(scanf("%d%d%d", &team_num, &prob_num, &R) && team_num){
        bool ac[team_num][prob_num];
        rep(i, team_num)rep(j, prob_num) ac[i][j] = false;
        vector<int> cnt(team_num, 0);
        vector<lint> penalty(team_num, 0);
        lint wa_cnt[team_num][prob_num];
        rep(i, team_num)rep(j, prob_num) wa_cnt[i][j] = 0;

        rep(_, R){
            int tID, pID, time; string message;
            cin >> tID >> pID >> time >> message;
            --tID; --pID;
            if(ac[tID][pID]) continue;
            else if(message == "CORRECT"){
                ac[tID][pID] = true;
                ++cnt[tID];
                penalty[tID] += wa_cnt[tID][pID] * 1200 + time;
            }
            else{
                ++wa_cnt[tID][pID];
            }
        }

        int id[team_num];
        rep(i, team_num) id[i] = i;
        sort(id, id+team_num, [&](const int &i, const int &j){
            if(cnt[i] == cnt[j]){
                if(penalty[i] == penalty[j]) return i < j;
                else return penalty[i] < penalty[j];
            }
            else return cnt[i] > cnt[j];
        });
        rep(i, team_num) printf("%d %d %lld\n", id[i]+1, cnt[id[i]], penalty[id[i]]);
    }
}

C++: #include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define REPW(i,n) for(i=0;i<(int)(n);++i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)   // c++14
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : " "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
    }
} before_main_function;
//------------------------------------------------------------------------------

struct team {
    int id;
    int ac_cnt;
    int penalty;
    vector<bool> ac;
    vector<int> wa;
};
bool cmp(const team &a, const team &b) {
    if(a.ac_cnt == b.ac_cnt) {
        if(a.penalty == b.penalty) {
            return a.id < b.id;
        }
        else return a.penalty < b.penalty;
    }
    else return a.ac_cnt > b.ac_cnt;
}
void solve(int T,int P,int R) {
    vector<team> t(T);
    REP(i,T) {
        t[i].id=i;
        t[i].ac=vector<bool>(P,false);
        t[i].wa=vector<int>(P,0);
    }
    REP(r,R) {
        int tid,pid,tm;
        string msg;
        cin>>tid>>pid>>tm>>msg;
        tid--;
        pid--;
        if(t[tid].ac[pid]) continue;
        if(msg=="CORRECT") {
            t[tid].penalty+=t[tid].wa[pid]*1200+tm;
            t[tid].ac[pid]=true;
            t[tid].ac_cnt++;
        }
        else {
            t[tid].wa[pid]++;
        }
    }
    sort(ALL(t),cmp);
    REP(i,T) {
        cout<<t[i].id+1<<" "<<t[i].ac_cnt<<" "<<t[i].penalty<<endl;
    }
}
signed main() {
    while(1) {
        int T,P,R;
        cin>>T>>P>>R;
        if((T+P+R)==0) break;
        solve(T,P,R);
    }
    return 0;
}