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()
}

Python: #!/usr/bin/env python
# -*- coding: utf-8 -*-

while True:
    T,P,R = map(int,input().split(" "))
    if T == 0 and P == 0 and R == 0:
        break
    teams = [[i,0,[0 for j in range(P)],0] for i in range(T)]
    for i in range(R):
        tID,pID,time,message = map(lambda x: int(x) -1 if x.isnumeric() else x,input().split())
        time += 1
        if message == "WRONG":
            teams[tID][2][pID] += 1
        elif message == "CORRECT" and teams[tID][2][pID] != -1:
            teams[tID][1] += 1
            teams[tID][3] += teams[tID][2][pID] * 1200 + time
            teams[tID][2][pID] = -1
    for t in sorted(teams,key = lambda x:(x[1],-x[3]),reverse=True):
        print(t[0] + 1,t[1],t[3])

Python: # coding: utf-8
while 1:
    t,p,r=map(int,input().split())
    if t==0:
        break
    teamdata=[[0,0,i+1,set()] for i in range(t)]
    data=[]
    for i in range(r):
        b,c,a,d=input().split()
        b,c,a=map(int,(b,c,a))
        if d=='CORRECT':
            teamdata[b-1][0]+=1
            teamdata[b-1][1]+=a
            teamdata[b-1][3].add(c)
        data.append([a,b,c,d])
    for a,b,c,d in data:
        if d!='CORRECT' and (c in teamdata[b-1][3]):
            teamdata[b-1][1]+=1200
    teamdata=sorted(teamdata, key=lambda x:(-x[0],x[1],x[2]))
    for i in range(t):
        print(teamdata[i][2],teamdata[i][0],teamdata[i][1])

Python: "審判は君だ！"
while True:
    T, P, R = map(int, input().split())  # 参加チーム数T, 問題数P, レコード数review
    if T == 0 and P == 0 and R == 0:
        break

    submits = []

    scores = {}
    for i in range(1, T+1):
        scores[i] = [0, 0]
    for i in range(R):
        tid, pid, time, message = map(str, input().split())
        tid = int(tid)
        pid = int(pid)
        time = int(time)
        submits.append([tid, pid, time, message])
    # print(scores)
    # print(submits)
    for i in range(len(submits)):
        if submits[i][3] == 'CORRECT':
            wa_cnt = 0
            for j in range(0, i):
                if submits[j][0] == submits[i][0] and submits[j][1] == submits[i][1]:
                    wa_cnt += 1
            scores[submits[i][0]][0] += 1
            scores[submits[i][0]][1] += (1200*wa_cnt + submits[i][2])

    scores = sorted(scores.items(), key=lambda x: (x[1][0], -x[1][1], -x[0]), reverse=True)
    # print(scores)
    for score in scores:
        print(score[0], score[1][0], score[1][1])

Python: while 1:
    T,P,R=map(int,input().split())
    if not T and not P and not R:break
    d={str(i):{str(j):[False,0] for j in range(1,P+1)} for i in range(1,T+1)}
    for _ in range(R):
        tid,pid,time,m=input().split()
        if not d[tid][pid][0]:
            if m=="WRONG":
                d[tid][pid][1]+=1
            else:
                d[tid][pid][0]=True
                d[tid][pid][1]=int(time)+d[tid][pid][1]*1200 
    l=[]
    for i in d.keys():
        cd=[j for j in d[i].values() if j[0]]
        sc=sum([j[1] for j in d[i].values()])
        l.extend([(int(i),len(cd),sc)])
    p=sorted(l,key=lambda x:(-x[1],x[2]))
    for i in p:
        print(i[0],i[1],i[2])

Python: while True:
    T, P, R = map(int, input().split())
    if T == 0 and P == 0 and R == 0:
        break
    correct = [[0] * (P+1) for _ in range(T+1)]
    wrong = [[0] * (P+1) for _ in range(T+1)]
    penalty = [0] * (T+1)
    for i in range(R):
        data = input().split()
        team = int(data[0])
        prob = int(data[1])
        time = int(data[2])
        if data[3] == 'WRONG':
            wrong[team][prob] += 1
        else:
            if correct[team][prob] == 0:
                correct[team][prob] = 1
                penalty[team] += wrong[team][prob]*1200 + time
    res = []
    for i in range(1,T+1):
        res.append((i, sum(correct[i]), penalty[i]))
        res.sort(key=lambda x:(x[1],-1*x[2],-1*x[0]), reverse=True)
    for i in range(T):
        print(res[i][0],res[i][1],res[i][2])

Python: while True:
    t, p, r = map(int, input().split())
    if t == p == r == 0:
        break

    data = [[0 for i in range(p + 1)] for i in range(t + 1)]
    for i in range(r):
        li = input().split()
        tid, pid, time = map(int, li[:3])
        if li[3] == "WRONG":
            data[tid][pid] -= 1
        else:
            data[tid][pid] = time - data[tid][pid] * 1200

    rank = list()
    for tid in range(1, t + 1):
        ans, pen = 0, 0
        for pid in range(1, p + 1):
            if data[tid][pid] > 0:
                ans -= 1
                pen += data[tid][pid]
        rank.append((ans, pen, tid))

    for ans, pen, tid in sorted(rank):
        print(tid, -ans, pen)

Python: while True:
    t, p, r = map(int, input().split())
    if t == p == r:
        break

    data = [[0 for i in range(p + 1)] for i in range(t + 1)]
    for i in range(r):
        li = input().split()
        tid, pid, time = map(int, li[:3])
        if li[3] == "WRONG":
            data[tid][pid] -= 1
        else:
            data[tid][pid] = time - data[tid][pid] * 1200

    rank = list()
    for tid in range(1, t + 1):
        ans, pen = 0, 0
        for pid in range(1, p + 1):
            if data[tid][pid] > 0:
                ans -= 1
                pen += data[tid][pid]
        rank.append((ans, pen, tid))

    for ans, pen, tid in sorted(rank):
        print(tid, -ans, pen)

C++: #include <cstring>
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main () {
	int t, p, r;
	while (cin >> t >> p >> r, t || p || r) {
		pair<int, pair<int, int> > team[t];
		int fail[t][p];
		memset(fail, 0, sizeof(fail));
		for (int i = 0; i < t; i++) {
			team[i].first = 0;
			team[i].second.first = 0;
			team[i].second.second = i;
		}
		for (int i = 0; i < r; i++) {
			int tid, pid, time;
			string msg;
			cin >> tid >> pid >> time >> msg;
			tid--; pid--;
			if (msg == "WRONG") {
				fail[tid][pid]++;
			}
			else {
				team[tid].first--;
				team[tid].second.first += time + 1200 * fail[tid][pid];
			}
		}
		sort(team, team + t);
		for (int i = 0; i < t; i++) {
			cout << team[i].second.second + 1 << ' ' << -team[i].first << ' ' << team[i].second.first << endl;
		}
	}
	return 0;
}