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: while True:
    T,P,R = map(int,input().split())
    if T == 0: break
    wrong = [[0 for i in range(P)] for j in range(T)]
    right = [0 for i in range(T)]
    pena = [0 for i in range(T)]
    for i in range(R):
        tid,pid,time,mes = input().split()
        tid,pid,time = int(tid)-1, int(pid)-1, int(time)
        if mes[0] == 'C':
            right[tid] += 1
            pena[tid] += wrong[tid][pid] * 1200 + time
        else:
            wrong[tid][pid] += 1
    result = []
    for i in range(T):
        result.append((-right[i], pena[i], i))
    for r,p,i in sorted(result):
        print('{0} {1} {2}'.format(i+1, -r, p))

Python: import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []

    while True:
        t,p,R = LI()
        if t == 0 and p == 0 and R == 0:
            break
        a = [LS() for _ in range(R)]
        r = [[0,0,i] for i in range(1,t+1)]
        gt = collections.defaultdict(int)
        for k in a:
            ti = int(k[0])
            pi = int(k[1])
            time = int(k[2])
            if k[3] == 'WRONG':
                gt[(ti,pi)] += 1
            else:
                r[ti-1][0] += 1
                r[ti-1][1] += gt[(ti,pi)] * 1200 + time

        r.sort(key=lambda x: [-x[0],x[1],x[2]])
        for s,t,ti in r:
            rr.append('{} {} {}'.format(ti, s, t))

    return '\n'.join(map(str, rr))


print(main())

Python: while True:
    t, p, r = map(int, input().split())
    if t == 0 and p == 0 and r == 0: break
    logs = [input().split() for _ in range(r)]
    score = [[0, 0, -i, [0] * p] for i in range(t)]
    c_n, pen, w_n = 0, 1, 3
    for tid, pid, time, msg in logs:
        tid, pid, time = int(tid) - 1, int(pid) - 1, int(time)
        if msg == 'WRONG':
            score[tid][w_n][pid] += 1
        elif msg == 'CORRECT':
            score[tid][c_n] += 1
            score[tid][pen] -= (score[tid][w_n][pid] * 1200 + time)
            score[tid][w_n][pid] = 0
    score = sorted(score, reverse=True)
    for c_n, pen, t, _ in score:
        print(abs(t) + 1 , c_n, abs(pen))

Python: 
class Score:
	def __init__(self, id, solve, penalty):
		self.id = id
		self.solve = solve
		self.penalty = penalty

	def __lt__(self, other):
		if (self.penalty == other.penalty) and (self.solve == other.solve):
			return self.id < other.id
		elif (self.solve == other.solve):
			return self.penalty < other.penalty
		else:
			return self.solve > other.solve

while True:
	t, p, r = map(int, input().split())
	if (t, p, r) == (0, 0, 0):
		break
	tp = [[0]*p for i in range(t)]
	ts = [Score(i+1,0,0) for i in range(t)]
	for i in range(r):
		tid, pid, time, message = input().split()
		tid, pid, time = map(int, [tid, pid, time])
		if message == 'CORRECT':
			ts[tid-1].solve += 1
			ts[tid-1].penalty += (tp[tid-1][pid-1]*1200 + time)
		else:
			tp[tid-1][pid-1] += 1
	ts = sorted(ts)
	for s in ts:
		print('{} {} {}'.format(s.id, s.solve, s.penalty))

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]*=1200
                d[tid][pid][1]+=int(time)
    l=[]
    for i in d.keys():
        cd=[j for j in d[i].values() if j[0]]
        sc=sum([j[1] for j in cd])
        l.extend([(int(i),len(cd),sc)])
    p=sorted(l,key=lambda x:(-x[1],x[2],x[0]))
    for i in p:
        print(i[0],i[1],i[2])

Python: #!/usr/bin/env python3
while True:
    T, P, R = map(int, input().split())
    if T == 0:
        exit()
    ans = [(0, 0, i) for i in range(T)]
    cs = [[0] * P for _ in range(T)]
    ws = [[0] * P for _ in range(T)]
    for _ in range(R):
        tid, pid, time, message = input().split()
        tid = int(tid) - 1
        pid = int(pid) - 1
        time = int(time)
        if message == 'CORRECT':
            s, p, t = ans[tid]
            if cs[tid][pid] > 0:
                continue
            ans[tid] = (s - 1, p + ws[tid][pid] * 1200 + time, tid)
            cs[tid][pid] += 1
        else:
            ws[tid][pid] += 1
    for s, p, t in sorted(ans):
        print(t + 1, -s, p)

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

    data = [[0 for i in range(3)] for j in range(t)]  # [ID, Solved, Penalty]
    wrong = [[0 for i in range(p)] for j in range(t)]
    for i in range(t):
        data[i][0] = i + 1

    for _ in range(r):
        log = list(input().split())
        team = int(log[0]) - 1
        quiz = int(log[1]) - 1
        time = int(log[2])
        flag = log[3]

        if flag == "CORRECT":
            data[team][1] += 1
            data[team][2] += (wrong[team][quiz] * 1200 + time)
        else:
            wrong[team][quiz] += 1

    data = sorted(data, key=lambda x: (-x[1], x[2], x[0]))
    for D in data:
        print(' '.join(str(d) for d in D))