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 <cstdio>
#include <utility>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#define REP(i,n) for(int i=0;i<n;i++)
typedef long long ll;
using namespace std;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;

int main() 
{
	
	int t,p,r;
	while( cin >> t >> p >> r && t!=0 && p!=0 && r!=0 )
	{
		
		int a[50][10]={}; //正答フラグ
		int b[50][10]={}; //得点フラグ
	
		REP(i,r){
			int x,y,z;
			string m;
			cin >> x >> y >> z >> m;
			x--;y--;
			if(m=="CORRECT"){
				a[x][y]=1;
				b[x][y]+=z;}
			else{
				if(a[x][y]==0){
				b[x][y] += 1200;}}}
		
		int c[50]={}; // 正答数
		int d[50]={}; // 得点
		
		REP(i,t){
		REP(j,p){c[i]+=a[i][j];d[i]+=a[i][j]*b[i][j];}}
		
		int e[50]={}; //順位
		
		REP(i,t){
			REP(j,t)
			{
				if(c[i]<c[j]){e[i]++;}
				else if(c[i]==c[j])
				{
					if(d[i]>d[j]){e[i]++;}
					else if(d[i]==d[j]){
						if(i>j){e[i]++;}
		}}}}
		
		REP(i,t)
		{
			REP(j,t)
			{
				if(i==e[j]){
							cout << j+1 << " " << c[j] << " " << d[j] << endl;
				}
			}
		}
		
	}
	return 0 ;
}

C++: //#define USE_CPP11
// #define USE_PRINTF

#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <utility>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#include <complex>
#include <memory>
#include <sstream>

#ifdef USE_CPP11
#include <unordered_map>
#include <unordered_set>
#include <functional>
#endif

#define PRINT(obj) cout << obj << endl
#define REP(i, n) for(int (i) = 0; (i) < (n); i++)
#define SPACE " "

typedef long long ll;

const int INF = 1e9 + 10;

using namespace std;

namespace Scanner {
#ifdef USE_PRINTF
  int    nextInt()    { int    d; scanf("%d" , &d); return d; }
  float  nextFloat()  { float  f; scanf("%f" , &f); return f; }
  double nextDouble() { double f; scanf("%lf", &f); return f; }  
  string nextString() { string s; scanf("%s" , &s); return s; }
  ll     nextll()     { ll     l; scanf("%ll", &l); return l; }
#else
  int    nextInt()    { int    d; cin >> d; return d; }
  float  nextFloat()  { float  f; cin >> f; return f; }
  double nextDouble() { double f; cin >> f; return f; }  
  string nextString() { string s; cin >> s; return s; }
  ll     nextll()     { ll     l; cin >> l; return l; }
#endif

  string getLine() { 
    string input;
    getline(cin, input);
    return input;
  }
};

namespace myLibrary {
  vector<string> split(const string& str, char delim) {
    vector<string> ret;
    size_t current = 0, found;
    while ((found = str.find_first_of(delim, current)) != string::npos) {
      ret.push_back(string(str, current, found - current));
      current = found + 1;
    }
    ret.push_back(string(str, current, str.size() - current));
    return ret;
  }
  
#ifdef USE_CPP11
  ///
  /// higher-order functional
  /// This is something like map in haskell, python, etc.
  /// Sample usage:
  ///   vector<int> a = {1, 2, 3, 4, 5};
  ///   vector<int> b = myLibrary::_Map<int, int>(a, [](int n){
  ///     return n * n;
  ///   });
  /// Result:
  ///   b = 1, 4, 9, 16, 25
  ///
  template<typename T_IN, typename T_OUT, class Functor>
  vector<T_OUT> _Map(vector<T_IN> src, Functor func) {
    vector<T_OUT> ret;
    for (int i = 0; i < src.size(); i++) {
      ret.push_back(func(src[i]));
    }
    return ret;
  }
#endif

};

/// BEGIN //////////////////////////////////////////////////////////

struct State {
public:
  int teamID;
  int acCount;
  int waCount[11];
  int penalty;

  State():acCount(0), penalty(0) { 
    memset(waCount, 0, sizeof(waCount));
  }
};

int main() {
  while (true) {
    int T = Scanner::nextInt();
    int P = Scanner::nextInt();
    int R = Scanner::nextInt();
    
    if (T + P + R == 0) {
      break;
    }

    vector<State> score(T);
    
    REP(i, T) {
      score[i].teamID = i + 1;
    }

    REP(i, R) {
      int tID        = Scanner::nextInt() - 1;
      int pID        = Scanner::nextInt() - 1;
      int time       = Scanner::nextInt();
      string message = Scanner::nextString();
      if (message == "WRONG") {
        score[tID].waCount[pID]++;
      } else if (message == "CORRECT") {
        score[tID].acCount++;
        score[tID].penalty += score[tID].waCount[pID] * 1200 + time;
      }
    }

    sort(score.begin(), score.end(), [](State a, State b) {
      if (a.acCount == b.acCount) {
        return a.penalty < b.penalty;
      } else {
        if (a.acCount == b.acCount) {
          return a.teamID < b.teamID;
        } else {
          return a.acCount > b.acCount;
        }
      }
    });

    REP(i, T) {
      cout << score[i].teamID << SPACE << score[i].acCount << SPACE << score[i].penalty << endl;
    }
  }  

  return 0;
}
/// END   //////////////////////////////////////////////////////////

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

struct team{
	int num;
	int ans;
	double time;
};

bool hikaku(const team &right,const team &left){
 if(right.ans == left.ans){
 	if(right.time == left.time){
 		return right.num < left.num;
 	}
 	return right.time < left.time;
 }
 else return left.ans < right.ans;
}

int main(){
	int t,p,r;
	int wrong[52][12];
	int res[52];
	double pe[52];
	vector<team> v;
	int tid,pid,time;
	string message;
	team te;
	while(1){
		cin >> t >> p >> r;
		if(t == 0)break;
		for(int i = 0;i <= t;i++){
			res[i] = 0;
			pe[i] = 0;
			for(int j = 0;j <= p;j++){
				wrong[i][j] = 0;	
			}
		}
		v.clear();
		for(int i = 0;i < r;i++){
			cin >> tid >> pid >> time >> message;
			if(message == "CORRECT"){
				res[tid]++;
				pe[tid] += wrong[tid][pid] * 1200 + time;
			}
			else if(message == "WRONG"){
				wrong[tid][pid]++;
			}
		}
		for(int i = 1;i <= t;i++){
			te.num = i;
			te.ans = res[i];
			te.time = pe[i];
			v.push_back(te);
		}
		sort(v.begin(),v.end(),hikaku);
		for(int i = 0;i < v.size();i++){
			cout << v[i].num << " " << v[i].ans << " " << v[i].time <<endl;
		}
	}
	return 0;
}