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++: // clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

struct ProbState {
  bool uresii = false;
  int kanasii = 0;
  int penalty;

  ProbState() {
  }
};

struct Team {
  vector<ProbState> states;
  int id;
  int solved  = 0;
  int penalty = 0;

  Team(int probs, int id)
    : states(probs), id(id) {
  }
};

bool operator<(const Team &a, const Team &b) {
  if (a.solved != b.solved) return a.solved > b.solved;
  return a.penalty < b.penalty;
}

void solve() {
  int t, p, r;
  while (cin >> t >> p >> r, t) {
    vector<Team> ts;
    ts.reserve(t);
    rep(i, t) ts.emplace_back(p, i + 1);
    while (r--) {
      int tid, pid, tm;
      string msg;
      cin >> tid >> pid >> tm >> msg;
      --tid, --pid;
      if (ts[tid].states[pid].uresii) continue;
      if (msg == "CORRECT") {
        ts[tid].states[pid].uresii = true;
        ts[tid].solved++;
        ts[tid].states[pid].penalty = ts[tid].states[pid].kanasii * 1200 + tm;
        ts[tid].penalty += ts[tid].states[pid].penalty;
      }
      if (msg == "WRONG") ts[tid].states[pid].kanasii++;
    }
    stable_sort(all(ts));
    for (Team x : ts) cout << x.id << ' ' << x.solved << ' ' << x.penalty << endl;
  }
}

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;
}

C++: #include<bits/stdc++.h>
using namespace std;

struct Team{
    int id, solved, penalty;
    bool operator<(const Team &obj) const{
        if(this->solved > obj.solved)return true;
        else if(this->solved < obj.solved)return false;
        else if(this->penalty < obj.penalty)return true;
        else if(this->penalty > obj.penalty)return false;
        else if(this->id < obj.id)return true;
        else return false;
    }
};

Team teams[51] = {0};
int penalties[51][11] = {0};

int main(){
    int t, p, r;
    while(scanf("%d %d %d",&t,&p, &r), t != 0){
        for(int i=0;i<50;++i){
            teams[i] = (Team){0,0,0};
            for(int j=0;j<10;++j){
                penalties[i][j] = 0;
            }
        }
        for(int i=0;i<t;++i)teams[i].id = i+1;
        for(int i=0;i<r;++i){
            int tid, pid, tm;
            string mes;
            cin >> tid >> pid >> tm >> mes;
            if(mes[0] == 'C'){
                teams[tid-1].solved++;
                teams[tid-1].penalty += penalties[tid-1][pid-1] * 1200 + tm;
            }else{
                penalties[tid-1][pid-1]++;
            }
        }
        sort(teams, teams+t);
        for(int i=0;i<t;++i)cout << teams[i].id << " " << teams[i].solved << " " << teams[i].penalty << endl;
    }

    return 0;
}

C++: #include <string>
#include <vector>
#include <numeric>
#include <iostream>

using namespace std;

int main()
{
	int T, P, R, A, B, C; string M;

	while (true)
	{
		cin >> T >> P >> R;

		if (T == 0 && P == 0 && R == 0) { break; }

		vector<int> S(T, 0);

		vector<vector<int> > W(T, vector<int>(P, 0));

		for (int i = 0; i < R; i++)
		{
			cin >> A >> B >> C >> M;

			if (M == "WRONG")
			{
				W[A - 1][B - 1] += 1;
			}
			else
			{
				S[A - 1] += (1000000 - W[A - 1][B - 1] * 1200 - C);
			}
		}

		vector<int> Q(T); iota(Q.begin(), Q.end(), 1);

		for (int i = 0; i < T; i++)
		{
			for (int j = i + 1; j < T; j++)
			{
				if (S[i] < S[j])
				{
					swap(S[i], S[j]); swap(Q[i], Q[j]);
				}
			}
		}

		for (int i = 0; i < T; i++)
		{
			cout << Q[i] << ' ' << S[i] / 1000000 << ' ' << (1000000 - S[i] % 1000000) % 1000000 << endl;
		}
	}

	return 0;
}