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 <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e10;
template<typename T> void cmax(T &a, T b) { a = max(a, b); }
template<typename T> void cmin(T &a, T b) { a = min(a, b); }

typedef struct Team {
  int WA[20] = {};
  int AC = 0;
  int score = 0;
  int ID;
  bool operator<(const Team &o) const {
    if (AC == o.AC) {
      if (score == o.score) {
        return ID < o.ID;
      } else {
        return score < o.score;
      }
    } else {
      return AC > o.AC;
    }
  }
} team;

signed main() {
  int T, P, R;
  while (1) {
    cin >> T >> P >> R;
    if (T == 0 && P == 0 && R == 0) break;
    vector<team> tm(T);
    rep(i, T) tm[i].ID = i + 1;

    rep(i, R) {
      int t, p, times;
      string s;
      cin >> t >> p >> times >> s;
      t--;
      p--;
      if (s == "CORRECT") {
        tm[t].AC++;
        tm[t].score += tm[t].WA[p] * 1200 + times;
      } else {
        tm[t].WA[p]++;
      }
    }
    sort(all(tm));
    rep(i, T) { cout << tm[i].ID << ' ' << tm[i].AC << ' ' << tm[i].score << endl; }
  }
  return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>

using namespace std;

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;

const int INF = INT_MAX / 4;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); i++ )
#define UREP( i, m, n ) for ( ui i = (ui)( m ); i < (ui)( n ); i++ )
#define EACH( v, c ) for ( __typeof( c.front() ) &v : c )

#define ITER( c ) __typeof( (c).begin() )
#define IREP( c, it ) for ( ITER(c) it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()
#define RALL( c ) (c).rbegin(), (c).rend()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

struct Team
{
	int no, solved, pena;
	map<int,int> submitted;

	Team( int n ) : no( n ), solved( 0 ), pena( 0 )
	{
		return;
	}

	void attempt( int n )
	{
		submitted[ n ]++;
		return;
	}

	void accept( int n, int time )
	{
		solved++;
		pena += submitted[n] * 1200 + time;
		return;
	}

	void print()
	{
		cout << no << ' ' << solved << ' ' << pena << endl;
	}

	bool operator < ( const Team &b ) const
	{
		if ( solved == b.solved )
		{
			if ( pena == b.pena )
			{
				return no < b.no;
			}
			else
			{
				return pena < b.pena;
			}
		}
		else
		{
			return b.solved < solved;
		}
	}
};

int main()
{
	while ( true )
	{
		int t, p, r;
		cin >> t >> p >> r;

		if ( t == 0 && p == 0 && r == 0 )
		{
			break;
		}

		vector<Team> ts;

		REP( i, 0, t )
		{
			ts.PB( Team( i + 1 ) );
		}

		int team, prob, time;
		string code;
		REP( i, 0, r )
		{
			cin >> team >> prob >> time >> code;

			if ( code == "CORRECT" )
			{
				ts[ team - 1 ].accept( prob, time );
			}
			else
			{
				ts[ team - 1].attempt( prob );
			}
		}

		sort( ALL( ts ) );

		for ( auto &t : ts )
		{
			t.print();
		}
	}

	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <complex>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <stack>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <cassert>

using namespace std;

typedef long long ll;
typedef ll li;
typedef pair<int,int> PI;
#define EPS (1e-10L)
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define F first
#define S second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int)((a).size())
#define ALL(a) a.begin(),a.end()
#define FOR(it,a) for(__typeof(a.begin())it=a.begin();it!=a.end();++it)
void pkuassert(bool t){t=1/t;};

int dx[]={0,1,0,-1,1,1,-1,-1};
int dy[]={1,0,-1,0,-1,1,1,-1};

int t,p,r;

void solve(){
  map<int,PI> app;
  rep(i,t) app[i+1]=mp(0,0);
  map<PI,int> tr;
  set<PI> ok;
  rep(i,r){
    int tid,pi,ti;
    string s;
    cin >> tid >> pi >> ti >> s;
    if(ok.count(mp(tid,pi))) continue;
    if(s[0]=='W'){
      tr[mp(tid,pi)]++;
    }else{
      ++app[tid].F;
      app[tid].S+=ti+tr[mp(tid,pi)]*1200;
      ok.insert(mp(tid,pi));
    }
  }
  vector<pair<PI,int> > team;
  FOR(it,app) team.pb(mp(mp(-it->S.F,it->S.S),it->F));
  sort(ALL(team));
  FOR(it,team) cout << it->S << ' ' << -it->F.F << ' ' << it->F.S << endl;
}

int main(int argc, char *argv[])
{
  while(cin >> t >> p >> r && t|p|r) solve();
  return 0;
}