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 <algorithm>
#include <array>
#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

struct team_t {
  array<uint32_t, 11> wrongs;
  uint64_t penalty;
  uint32_t corrects;
  uint32_t id;
  team_t() : wrongs({}), penalty(0), corrects(0), id(0) {}

  void correct(uint32_t pid, uint32_t time) {
    corrects++;
    penalty += 1200 * wrongs[pid] + time;
  }

  void wrong(uint32_t pid) { wrongs[pid]++; }

  void println() { cout << id << " " << corrects << " " << penalty << endl; }

  bool operator<(const team_t &team) const {
    return corrects == team.corrects ? penalty < team.penalty
                                     : corrects > team.corrects;
  }
};

int32_t main() {
  while (true) {
    uint32_t T, P, R;
    cin >> T >> P >> R;
    if (T == 0) break;

    vector<team_t> teams(T + 1);
    for (uint32_t i = 1; i <= T; i++) {
      teams[i].id = i;
    }

    for (uint32_t i = 0; i < R; i++) {
      uint32_t tid, pid, t;
      string msg;
      cin >> tid >> pid >> t >> msg;
      if (msg == "WRONG") {
        teams[tid].wrong(pid);
      } else if (msg == "CORRECT") {
        teams[tid].correct(pid, t);
      }
    }

    sort(teams.begin() + 1, teams.begin() + T);

    for (uint32_t i = 1; i <= T; i++) {
      teams[i].println();
    }
  }

  return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<functional>
#include<stack>

using namespace std;

int T[100000], P[10000], R[10000], tID[10000][500], pID[10000][500], time[10000][500], msg[10000][500], n = 0;

int main() {
	while (cin >> T[n] >> P[n] >> R[n]) {
		if (T[n] == 0)break;
		for (int j = 0; j < R[n]; j++) {
			string messege;
			cin >> tID[n][j] >> pID[n][j] >> time[n][j] >> messege;
			if (messege == "CORRECT")msg[n][j] = 1;
			else msg[n][j] = 0;
		}
		n++;
	}
	for (int i = 0; i < n; i++) {
		vector<pair<int, int>> AP, temp;
		AP.resize(T[i]);
		int WA[50][10]{ 0 };
		for (int j = 0; j < R[i]; j++) {
			if (msg[i][j] == 0) {
				WA[tID[i][j] - 1][pID[i][j] - 1]++;
			}
			else {
				AP[tID[i][j] - 1].first--;
				AP[tID[i][j] - 1].second += time[i][j] + WA[tID[i][j] - 1][pID[i][j] - 1] * 1200;
			}
		}
		temp = AP;
		sort(temp.begin(), temp.end());
		int j = 0, k = 0, memo[50]{0};
		while (j < T[i]) {
			if (memo[k] > 0) {
				k++;
				continue;
			}
			if (temp[j] == AP[k]) {
				cout << k + 1 << " " << -temp[j].first << " " << temp[j].second << endl;
				j++;
				memo[k]++;
				k = 0;
			}
			else k++;
		}
	}
	return 0;
}

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

# define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

class team {
  public:
    long long tid;
    long long score = 0;
    long long penalty = 0;
    void print();
    bool operator < (const team &right) {
      if (score > right.score) return true;
      else return penalty > right.penalty;
    }
};

void team::print() {
  cout << tid << ' ' << score << ' ' << penalty << endl;
}


int main() {
  long long t, p, r;
  long long tid, pid, time_;
  string message;

  while (cin >> t >> p >> r && t && p && r) {
    vector<long long> corrects(t);
    vector<long long> penalties(t);
    vector<vector<long long>> wrongs(t);

    fill(corrects.begin(), corrects.end(), 0);
    fill(penalties.begin(), penalties.end(), 0);
    rep (i, t) {
      vector<long long>w(p);
      fill(w.begin(), w.end(), 0);
      wrongs[i] = w;
    }


    rep (i, r) {
      cin >> tid >> pid >> time_ >> message;
      tid--; pid--;

      if (message == "CORRECT") {
        corrects[tid]++;
        long long point = wrongs[tid][pid] * 1200 + time_;
        // cout << "team id: " << tid << endl;
        // cout << "penalty: " << penalties[tid] << endl;
        // cout << "wrongs[tid][pid]: " << wrongs[tid][pid] << endl;
        // cout << "point: " << point << endl;
        penalties[tid] += point;
      }
      else if (message == "WRONG") {
        wrongs[tid][pid]++;
      }
    }

    vector<team> teams(t);

    rep (i, t) {
      teams[i].tid = i+1;
      teams[i].score = corrects[i];
      teams[i].penalty = penalties[i];
    }

    sort(teams.begin(), teams.end());
    rep (i, t) teams[i].print();
  }
}

C++: #include <cstdio>
#include <cctype>
#include <utility>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;while(isspace(c)){c=gcu();}if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m?-n:n;}
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(bool b) {pcu('0'+b);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_vo(string s){for(char c:s)pcu(c);}
#endif
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

struct team {
	int id, s = 0, t = 0;
	vector<int> w;
	bool operator < (team a) {
		return s == a.s ? t == a.t ? id < a.id : t < a.t : s > a.s;
	}
};

int main() {
	for (int T, P, R; T = in(), P = in(), R = in();) {
		vector<team> t(T);
		int i = 1;
		for (team &x: t) {
			x.id = i++;
			x.w = vector<int>(P);
		}
		int p, s;
		string m;
		while (R--) {
			scan(i, p, s, m);
			auto &u = t[i - 1];
			if (m[0] == 'C') {
				u.s++;
				u.t += u.w[p - 1] * 1200 + s;
			} else
				u.w[p - 1]++;
		}
		sort(t.begin(), t.end());
		for (team x: t)
			outl(x.id, ' ', x.s, ' ', x.t);
	}
}