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>
#include <stdint.h>

typedef uint32_t u32;
typedef uint64_t u64;

class Team {
public:
  Team();
  void AC(long problem_id, long time);
  void WA(long problem_id, long time);
  long Polong() const;
  long Num_AC() const;
  void Dump();
  void Setid(long id_);
private:
  long miss[16];
  bool correct[16];
  long polong;
  long num_ac;
  long id;
};

Team::Team() {
  for(long i = 0; i < 16; ++i) {
    miss[i] = 0;
    correct[i] = false;
  }
  polong = 0;
  num_ac = 0;
}

void Team::AC(long problem_id, long time) {
  correct[problem_id] = true;
  polong += miss[problem_id] * 1200 + time;
  num_ac += 1;
}

void Team::WA(long problem_id, long time) {
  correct[problem_id] = false;
  miss[problem_id] += 1;
}

long Team::Polong() const {
  return polong;
}

long Team::Num_AC() const {
  return num_ac;
}

void Team::Setid(long id_) {
  id = id_;
}

void Team::Dump() {
  std::cout << id << ' ' << Num_AC() << ' ' << polong << std::endl;
}

bool operator < (const Team& left, const Team& right) {
  if( left.Num_AC() != right.Num_AC() ) return -left.Num_AC() < -right.Num_AC();
  return left.Polong() < right.Polong();
}

int main() {

  for(;;) {
    long T, P, R;
    std::cin >> T >> P >> R;
    if( T == 0 and P == 0 and R == 0 ) break;
    long tID, pID, time;
    std::string message;
    Team team[64];
    for(long i = 0; i < 64; ++i) {
      team[i].Setid(i);
    }                                 
    for(long i = 0; i < R; ++i) {
      std::cin >> tID >> pID >> time;
      std::cin >> message;
      if( message == "CORRECT" ) {
        team[tID].AC(pID, time);
      }
      else {
        team[tID].WA(pID, time);
      }
    }
    std::sort(team+1, team+T+1);
    for(long i = 1; i <= T; ++i) {
      team[i].Dump();
    }
  }  
  
  return 0;
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

class Info{
public:
	int id, ac, penalty;
	Info(int i=0, int a=0, int p=0) : id(i), ac(a), penalty(p) {}
	bool operator < (const Info& i) const {
		if(ac != i.ac) return ac > i.ac;
		if(penalty != i.penalty) return penalty < i.penalty;
		return id < i.id;
	}
};

int main(){
	int cnt[50][10];
	int T, P, R;
	while(cin >> T >> P >> R && T){
		for(int i=0;i<T;i++){
			for(int j=0;j<P;j++){
				cnt[i][j] = 0;
			}
		}
		vector<Info> vi(T);
		for(int i=0;i<T;i++) vi[i].id = i+1;
		for(int i=0;i<R;i++){
			int tID, pID, time;
			string message;
			cin >> tID >> pID >> time >> message;
			tID--; pID--;
			if(cnt[tID][pID] == -1) continue;
			if(message == "CORRECT"){
				vi[tID].ac++;
				vi[tID].penalty += time + 1200*cnt[tID][pID];
				cnt[tID][pID] = 0;
			} else {
				++cnt[tID][pID];
			}
		}
		sort(vi.begin(), vi.end());
		for(Info in : vi){
			cout << in.id << " " << in.ac << " " << in.penalty << endl;
		}
	}
}

C++: #include <bits/stdc++.h>
using namespace std ;

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}
template<typename T,typename U>
ll FindErase(T &v,U tar){
  ll cnt = 0;
  for(auto it = v.begin(); it != v.end();){
    if(*it == tar){
      it = v.erase(it);
      ++cnt;
    }
    else{
      ++it;
    }
  }
  return cnt;
}

template<typename T>
bool SuffixErase(T &v,size_t suf){
  if(suf > v.size()) return false;
  for(auto it = v.begin(); it != v.end();){
    if(distance(v.begin(),it) == suf){
      v.erase(it);
      return true;
    }
    else{
      ++it;
    }
  }
  return false;
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}
struct data{
  ll id,ac,pn;
  vector<ll> wa;
  bool operator<(const data& d){
    if(ac == d.ac && pn == d.pn){
      return id < d.id;
    }
    if(ac == d.ac){
      return pn < d.pn;
    }
    return ac > d.ac;
  }
};
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll t,r,p;
  while(cin >> t >> p >> r && t+r+p ){
    vector<data> vd(t);
    rep(i,t){
      vd[i].id = i+1;
      vd[i].wa.resize(p);
    }
    ll ti,pi,time;
    string mes;
    rep(i,r){
      cin >> ti >> pi >> time >> mes;
      --ti,--pi;
      if(mes == "WRONG"){
        vd[ti].wa[pi]++;
      }
      else{
        vd[ti].ac++;
        vd[ti].pn += vd[ti].wa[pi] * 1200 + time;
      }
    }
    sort(all(vd));
    rep(i,t){
      cout << vd[i].id << ' ' << vd[i].ac << ' ' << vd[i].pn << endl;
    }
  }
  return 0;
}