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>
using namespace std;

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) {
        ll d = euclid(b, a % b, y, x);
        return y -= a / b * x, d;
    }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1)
            ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1);
        return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e)
            return Mod(1);
        Mod r = *this ^ (e / 2);
        r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

int main() {
    cin.sync_with_stdio(0);
    cin.tie(0);
    cin.exceptions(cin.failbit);

    while (true) {
        int T, P, R; cin >> T >> P >> R;
        if (!T) break;

        map<int, map<int, int>> penq;
        map<int, int> ttlpen;
        map<int, int> solved;

        rep(i, 0, R) {
            int t, p, time; string msg;
            cin >> t >> p >> time >> msg;
            if (msg == "CORRECT") {
                ttlpen[t] += penq[t][p] * 1200 + time;
                solved[t]++;
            } else {
                penq[t][p]++;
            }
        }

        vector<pair<pii, int>> ranks;
        rep(i, 1, T + 1) {
            ranks.push_back({{-solved[i], ttlpen[i]}, i});
        }
        sort(all(ranks));
        for (auto p : ranks) {
            cout << p.second << " " << -p.first.first << " " << p.first.second << endl;
        }
    }
}

C++: #include <bits/stdc++.h>

using namespace std;

#define REP(i, n) for (int i=0; i<(n); ++i)
#define RREP(i, n) for (int i=(int)(n)-1; i>=0; --i)
#define FOR(i, a, n) for (int i=(a); i<(n); ++i)
#define RFOR(i, a, n) for (int i=(int)(n)-1; i>=(a); --i)

#define SZ(x) ((int)(x).size())
#define all(x) begin(x),end(x)

#define dump(x) cerr<<#x<<" = "<<(x)<<endl
#define debug(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl;

template<class T>
ostream &operator<<(ostream &os, const vector <T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

template<class T, class U>
ostream &operator<<(ostream &os, const pair <T, U> &p) {
    return os << "(" << p.first << " " << p.second << ")";
}

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 (b < a) {
        a = b;
        return true;
    }
    return false;
}

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
const ld EPS = 1e-9;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    for (;;) {
        int T, P, R; cin >> T >> P >> R;
        if (T == 0) break;

        vvi penalty(T, vi(P));
        vi totalPenalty(T), totalAC(T);
        REP(i, R) {
            int tid, pid, time; string msg;
            cin >> tid >> pid >> time >> msg;
            --tid, --pid;

            if (msg == "WRONG") {
                ++penalty[tid][pid];
            } else {
                totalPenalty[tid] += 1200 * penalty[tid][pid] + time;
                ++totalAC[tid];
            }
        }

        vi ord(T);
        iota(all(ord), 0);
        sort(all(ord), [&](int i,int j){
            if (totalAC[i] != totalAC[j]) return totalAC[i] > totalAC[j];
            if (totalPenalty[i] != totalPenalty[j]) return totalPenalty[i] < totalPenalty[j];
            return i < j;
        });

        REP(i, T) {
            cout << ord[i]+1 << " " << totalAC[ord[i]] << " " << totalPenalty[ord[i]] << endl;
        }
    }

    return 0;
}

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

class TEAM{
  public:
    ll solved;
    ll wrong;
    ll pen;
    ll id;
    vector<int> problem;
    TEAM(ll n){
      solved = 0;
      wrong = 0;
      pen = 0;
      problem = vector<int>(n, 0);
    }
    bool operator<(const TEAM &a)const{
      if(solved == a.solved){
        if(pen == a.pen){
          return id < a.id;
        }else{
          return pen < a.pen;
        }
      }else{
        return solved > a.solved;
      }
    }
    bool operator==(const TEAM &a)const{
      return solved == a.solved && pen == a.pen;
    }
};

int main(void){
  ll T, P, R;
  while(cin >> T >> P >> R, T | P | R){
    vector<TEAM> team(T, TEAM(P));
    for(ll i=0; i < T; i++){
      team[i].id = i+1;
    }
    while(R--){
      ll tID, pID, time; string message;
      cin >> tID >> pID >> time >> message;
      tID--; pID--;
      if(message == "CORRECT"){
        team[tID].solved++;
        team[tID].pen += team[tID].problem[pID] * 1200 + time;
      }else{
        team[tID].problem[pID]++;
      }
    }
    stable_sort(team.begin(), team.end());
    for(ll i=0;  i< T; i++){
      cout << team[i].id << " " << team[i].solved << " " << team[i].pen << endl;
    }
  }
  return 0;
}