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 <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
#define UNSOLVED -1
#define CORRECT   0
#define WRONG	    1

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

struct TEAM{
	int tid;	// チームのID
	int ac;	// 正解数
	int sum_pa;	// トータルのペナルティー
	int st[12];	// 問題の状態	UNSOLVED CORRECT WRONG
	int wa[12];	// 各問題の誤答数
	int pa[12];	// 各問題のペナルティー

	bool operator<( const TEAM & right ) const {
		return (ac != right.ac ? ac > right.ac : ( sum_pa != right.sum_pa ? sum_pa < right.sum_pa : tid < right.tid ) );
	} 
};

	
int main()
{
	ios_base::sync_with_stdio(0);
	int T, P, R;	// T: 参加チーム数 P: 問題数 R: レコード数
	while (cin >> T >> P >> R, T ){
		TEAM t[T];
		rep (i, T ){
			t[i].tid = i+1, t[i].ac = 0, t[i].sum_pa = 0;
			rep (j, P ) t[i].st[j] = UNSOLVED, t[i].wa[j] = 0, t[i].pa[j] = 0;
		} // end rep
		rep (i, R ){
			int tid, pid, tm; string mes;
			cin >> tid >> pid >> tm >> mes;
			tid--; pid--;
			if (mes == "WRONG" ){
				t[tid].wa[pid]++;
				t[tid].st[pid] = WRONG;
			}else{	// mes == "CORRECT"
				t[tid].st[pid] = CORRECT;
				t[tid].pa[pid] = t[tid].wa[pid]*1200 + tm;
			} // end if
		} // end rep
		rep (i, T ){
			rep (j, P ){
				if (t[i].st[j] == CORRECT ){
					t[i].ac++;
					t[i].sum_pa += t[i].pa[j];
				} // end if
			} // end rep
		} // end rep
		sort (t, t+T );
		rep (i, T ){
			cout << t[i].tid << ' ' << t[i].ac << ' ' << t[i].sum_pa << endl;
		} // end rep
	} // end while
	
	return 0;
}

C++: #define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define EPS 1e-10
using namespace std;
typedef long long llong;
class team {
public:
	int ac = 0, pe = 0, tid;
	vector<int>pid;

	bool operator <(team &other)const {
		if (this->ac == other.ac&&this->pe == other.pe)return this->tid < other.tid;
		else if (this->ac == other.ac)return this->pe < other.pe;
		else return this->ac > other.ac;
	}

};
int main() {
	int t, p, r;
	while (cin >> t >> p >> r,t||p||r) {
		vector<team>v(t);
		for (int i = 0; i < t; i++) {
			v[i].tid = i;
			v[i].pid = vector<int>(p, 0);
		}
		for (int i = 0; i < r; i++) {
			int tid, pid, time;
			string mes;
			cin >> tid >> pid >> time >> mes;
			tid--;
			pid--;
			if (mes == "WRONG") {
				v[tid].pid[pid]++;
			}
			else if (mes == "CORRECT") {
				v[tid].ac++;
				v[tid].pe += v[tid].pid[pid] * 1200 + time;
			}

		}
		sort(v.begin(), v.end());
		for (auto it = v.begin(); it != v.end(); it++) {
			cout << it->tid + 1 << " " << it->ac << " " << it->pe << endl;
		}
	}

	return 0;
}

C++: //
//  main.cpp
//  c
//
//  Created by 13B10694 on 2015/06/01.
//  Copyright (c) 2015????´ 13B10694. All rights reserved.
//

#include <iostream>
#include <vector>
#include<stdio.h>
#include <algorithm>
#include<string.h>
using namespace std;

int now=1;

class team{
    
public:
    int id, pen, sol;
    int wrong[12];
    vector <int> solved;
    team(){
        memset(wrong, 0, sizeof(wrong));
        id=now++;
        pen=0;sol=0;
    }
    ~team(){
       // solved.clear();
    }
    
    bool operator < (const team& b) const
    {
        return solved.size()==b.solved.size() ? pen== b.pen ? id<b.id : pen<b.pen : solved.size()>b.solved.size();
    }
};

int main() {
    int t,p,r;
    while(cin>>t>>p>>r,t){
        now=1;
        vector<team> tea(t);

        for(int i=0;i<r;i++){
            int ti, pi, tim;
            string mes;
            cin>>ti>>pi>>tim>>mes;
            ti-=1;
            if(mes=="WRONG"){
                tea[ti].wrong[pi]++;
                continue;
            }
            if(find(tea[ti].solved.begin(),tea[ti].solved.end(),pi)!=tea[ti].solved.end()){
                continue;
            }
            tea[ti].solved.push_back(pi);
            tea[ti].pen += tea[ti].wrong[pi]*1200+tim;
  
        }
        sort(tea.begin(),tea.end());
        for(int i=0;i<t;i++){
            cout<<tea[i].id<<" "<<tea[i].solved.size()<<" "<<tea[i].pen<<endl;
        }
        tea.clear();
    }
    
    return 0;
}

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

typedef struct TreamInfo
{
    int tID;
    int points;
    int pena;
    int ProbMiss[10];

    TreamInfo(int tid) : tID(tid) {}
} TeamInfo;

bool cmp(const TeamInfo &a, const TeamInfo &b)
{
    return (a.points == b.points)?(a.pena == b.pena? a.tID < b.tID:a.pena < b.pena):(a.points > b.points);
}

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

        vector<TeamInfo> v;

        for (size_t i = 0; i < t; i++)
        {
            v.push_back(TeamInfo(i+1));
        }

        for (size_t i = 0; i < r; i++)
        {
            int tID, pID, tim;
            string mess;
            cin >> tID >> pID >> tim >> mess;

            if (mess == "CORRECT")
            {
                v[tID - 1].points += 1;
                v[tID - 1].pena += ((v[tID - 1].ProbMiss[pID - 1]) * 1200) + tim;
            }
            if (mess == "WRONG")
            {
                v[tID - 1].ProbMiss[pID - 1] += 1;
            }
        }
        // for (size_t i = 0; i < t; i++)
        // {
        //     cout << "team " << i <<" point is " <<v[i].points << endl;
        //     cout << "team " << i << " pena is " << v[i].pena << endl;
        // }

        sort(v.begin(), v.end(), cmp);
        for (size_t i = 0; i < t; i++)
        {
            cout << v[i].tID <<" "<< v[i].points <<" "<< v[i].pena << endl;
        }
    }
    return 0;
}