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++: // 2016-12-10
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
using namespace std;

int main() {
	int t, p, r, ti, pi, tt;
	int c[50], w[50][10], a[50];
	string m;
	while (cin >> t >> p >> r, t) {
		for (int i = 0; i < t; i++) {
			c[i] = 0;
			a[i] = 0;
			for (int j = 0; j < p; j++) {
				w[i][j] = 0;
			}
		}
		for (int i = 0; i < r; i++) {
			cin >> ti >> pi >> tt >> m;
			if (m[0] == 'C') {
				c[ti - 1]++;
				a[ti - 1] += w[ti - 1][pi - 1] * 1200 + tt;
			} else {
				w[ti - 1][pi - 1]++;
			}
		}
		vector<pair<pair<int, int>, int>> v;
		for (int i = 0; i < t; i++) {
			v.push_back(make_pair(make_pair(p - c[i], a[i]), i));
		}
		sort(begin(v), end(v));
		for (int i = 0; i < t; i++) {
			cout << v[i].second + 1 << ' ' << p - v[i].first.first << ' ' << v[i].first.second << endl;
		}
	}
	return 0;
}

C++: #include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1 << 28;
//constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;


struct SCORE {
	ll ac, pena, id;
	SCORE(ll _ac, ll _pena, ll _id) :ac(_ac), pena(_pena), id(_id) {}
	SCORE() :ac(0), pena(0), id(0) {}
	bool operator<(const SCORE& s) {
		if (ac == s.ac) {
			if (pena == s.pena) return id < s.id;
			else return pena < s.pena;
		}
		else {
			return ac > s.ac;
		}
	}
	bool operator ==(const SCORE& s) {
		return pena == s.pena && ac == s.ac;
	}
};
int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/
	int kkt = 89;
	while (kkt) {
		ll T, P, R; scanf("%lld %lld %lld",&T, &P, &R); if (T == 0 && P == 0 && R == 0) break;
		vector<SCORE> score(T); for (int i = 0; i < T; i++) score[i].id = i + 1;
		vector<vector<ll>> miss(T, vector<ll>(P));
		for (int i = 0; i < R; i++) {
			ll m, t, p; scanf("%lld %lld %lld", &t,&p,&m); t--; p--;
			string s; cin >> s;
			int j = 0;
			if (s == "WRONG") j = 1;
			if (j == 0) {
				score[t].ac++;
				score[t].pena += m + miss[t][p];
			}
			else {
				miss[t][p] += 1200;
			}
		}
		sort(score.begin(), score.end());
		for (int i = 0; i < T; i++) {
			cout << score[i].id << " " << score[i].ac << " " << score[i].pena << "\n";
		}
	}
	return 0;

}

C++: #include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
 
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define _D(p) std::cout<<"L"<<__LINE__<<" : " #p " = "<<(p)<<std::endl;
#define _D2(p,q) std::cout<<"L"<<__LINE__<<" : " #p " = "<<(p) << ", " #q " = "<<(q)<<std::endl;
#define _DN(v) std::cout<<"L"<<__LINE__<<" : " #v " = ["; rep(i,(v).size()) {std::cout<<v[i]<<(i==v.size()-1?"":", ");}std::cout<<"]"<<std::endl;
#define _DNN(v) std::cout<<"L"<<__LINE__<<" : " #v " = [" << std::endl; rep(i,(v).size()) {std::cout<<"	[";rep(j,(v)[0].size()){std::cout<<v[i][j]<<(j==v[0].size()-1?"":", ");}std::cout<<"],"<<std::endl;}std::cout<<"]"<<std::endl;
 
using namespace std;
 
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
 
const int INF=1<<29;
const double EPS=1e-9;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

struct Team
{
	int id;
	int ac = 0;
	int pena = 0;
	int tried[10] = {};
};
int main(int argc, char const *argv[]) {
	int T, P, R;

	while(cin >> T >> P >> R)
	{
		if(T == 0 && P == 0 && R == 0) break;

		vector<Team> teams(T);

		for(int i = 0; i < T; ++i)
		{
			teams[i].id = i + 1;
		}

		for (int i = 0; i < R; ++i) {
					int tID;
					int pID;
					int itime;
					string str;
					cin >> tID >> pID >> itime >> str;
					tID--;
					pID--;
					if(str == "CORRECT")
					{
						teams[tID].ac++;
						teams[tID].pena += teams[tID].tried[pID] * 1200 + itime; 
					}
					else
					{
						teams[tID].tried[pID]++;
					}
				}

		stable_sort(all(teams), [](Team a, Team b){return a.pena < b.pena;});
		stable_sort(all(teams), [](Team a, Team b){return a.ac > b.ac;});

		for(auto e : teams)
		{
			cout << e.id << ' ' << e.ac << ' ' << e.pena << endl;
		}
	}

	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
struct N {
  int i;
  ll pen, cor;
  ll v[10];
};
bool operator<(const N &l, const N &r) {
  if (l.cor == r.cor) {
    if (l.pen == r.pen)
      return l.i < r.i;
    return l.pen < r.pen;
  }
  return l.cor > r.cor;
}

int main() {
  while (true) {
    int t, p, r;
    cin >> t >> p >> r;
    if (t == 0)
      break;
    vector<N> teams(t);
    for (int i = 0; i < t; i++)
      teams[i].i = i;
    for (int i = 0; i < r; i++) {
      int tid, pid, time;
      string s;
      cin >> tid >> pid >> time >> s;
      tid--;
      pid--;
      if (s == "CORRECT" && teams[tid].v[pid] >= 0) {
        teams[tid].cor++;
        teams[tid].pen += time + teams[tid].v[pid] * 1200;
        teams[tid].v[pid] = -1;
      }
      if (s == "WRONG" && teams[tid].v[pid] >= 0) {
        teams[tid].v[pid]++;
      }
    }
    sort(teams.begin(), teams.end());
    for (int i = 0; i < t; i++)
      cout << teams[i].i + 1 << " " << teams[i].cor << " " << teams[i].pen
           << endl;
  }
  return 0;
}