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>
#define REP(i,n) for(i=0; i<n; i++)
#define IREP(i,n) for(i=n-1; i>=0; i--)
#define X first
#define Y second;
using namespace std;

int main() {
	int T,P,R,i,j,t,p,ti;
	string m;
	cin >> T >> P >> R;
	int a[T][P];
	int c[T];
	int x[T];
	REP(i,T) {
		REP(j,P) a[i][j]=0;
		c[i]=0;
	}
	REP(i,R) {
		cin >> t >> p >> ti >> m;
		if(m.compare("WRONG")==0) a[t][p]++;
		else if(m.compare("CORRECT")==0) {
			c[i]++;
			x[i]+=1200*a[t][p]+ti;
		}
	}
	int b[T];
	REP(i,T) {
		int junni=1;
		REP(j,T) {
			if(i==j) continue;
			if(c[i]<c[j]) junni++;
			else if(x[i]>x[j]) junni++;
			else if(i>j) junni++;
			b[j]=i;
		}
	}
	REP(i,T) {
		cout << b[i] << c[b[i]] << x[b[i]] << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
	while(1){
		int t,p,r;
		cin >> t >> p >> r;
		if(t==0) break;
		pair<int,pair<int,int> > data[51]; //?§£????????????????????°,Penalty,TeamID		
		int WAnum[51][11];
		REP(i,51){
			REP(j,11) WAnum[i][j] = 0;
			data[i].first = p;
			data[i].second.first = 0;
			data[i].second.second = i;
		}
		REP(i,r){
			int tid,pid,tt;
			string ms;
			cin >> tid >> pid >> tt >> ms;
			tid--;
			if(ms=="WRONG"){
				WAnum[tid][pid]++;
			}else if(ms=="CORRECT"){
				data[tid].first--;
				data[tid].second.first += (WAnum[tid][pid]*1200+tt);
			}
		}
		sort(data,data+t);
		REP(i,t){
			cout << data[i].second.second+1 << " " << p-data[i].first <<" "<< data[i].second.first << endl;
		}
	}
}

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 correct;
    long long penalty;
    void print();
    bool operator < (const team&);
};

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

bool team::operator < (const team &right) {
  if (correct != right.correct) return correct > right.correct;
  else if (penalty != right.penalty) return penalty < right.penalty;
  else return tid < right.tid;
}

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

  while (cin >> t >> p >> r && t && p && r) {
    vector<team> teams(t);
    vector<long long> corrects(t, 0);
    vector<long long> penalties(t, 0);
    vector<vector<long long>> wrongs(t);
    rep (i, t) wrongs[i].resize(p);

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

      if (message == "CORRECT") {
        corrects[tid]++;
        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]++;
      }
    }

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

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

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

using namespace std;

int T[1000], P[1000], R[1000], tID[1000][500], pID[1000][500], Time[1000][500], msg[1000][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;
}