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++: //#define _GRIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;

// ?????¬???????????¬??????
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// ???
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long double> vld;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// ?????°
#pragma region CONST_VAL
constexpr int PI = (2*acos(0.0));
constexpr int EPS = (1e-9);
constexpr int MOD = (int)(1e9+7);
constexpr int INF = 100000000;
#pragma endregion


int main()
{
    int t, p, r;
    while(cin>>t>>p>>r, t) {
        vector<vector<int> > v(t, vector<int>(3, 0));
        for(int i=0; i<t; ++i) v[i][2] = i;
        vector<vector<int> > wa(t, vector<int>(p, 0));
        while(r--) {
            int tid, pid, tim;
            string m;
            cin >> tid >> pid >> tim >> m;
            tid--;
            pid--;
            if(m[0]=='C') {
                v[tid][0]++;
                v[tid][1] += wa[tid][pid]*1200 + tim;
            }
            else wa[tid][pid]++;
        }

        for(int i=0; i<t; ++i) v[i][0] *= -1;
        sort(ALL(v));
        for(int i=0; i<t; ++i) v[i][0] *= -1;
        for(auto u : v) cout << u[2]+1 << " " << u[0] << " " << u[1] << endl;
    }
    return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;

struct team{
  int tid;
  int pen;
  int ans;
};


bool comp (const struct team x1,const struct team x2)
{
  if(x1.ans>x2.ans)
    return true;
  else if(x1.ans<x2.ans)
    return false;
  else
    {
      if(x1.pen<x2.pen)
	return true;
      else if(x1.pen>x2.pen)
	return false;
      else
	{
	  if(x1.tid<x2.tid)
	    return true;
	  else if(x1.tid>x2.tid)
	    return false;
	}
      
    }
}


int main()
{
  int t,p,r;
  while(true)
    {
      cin>>t;
      cin>>p;
      cin>>r;
      if(t==0)
	exit(0);

      vector<team> d;
      for(int i=0;i<p;i++)
	{
	  struct team x;
	  x.tid=i+1;
	  x.pen=0;
	  x.ans=0;
	  d.push_back(x);
	}
      int miss[51][51]={0};

      for(int i=0;i<r;i++)
	{
	  int t,p,time;
	  string mess;
	  cin>>t;
	  cin>>p;
	  cin>>time;
	  cin>>mess;
	  if(mess=="WRONG")
	    {
	      miss[p][t]+=1;
	    }
	  else
	    {
	      d[t-1].ans+=1;
	      d[t-1].pen+=(miss[p][t]*1200)+time;	      
	    }
	}
      sort(d.begin(),d.end(),comp);
      for(int i=0;i<d.size();i++)
	{
	  printf("%d %d %d\n",d[i].tid,d[i].ans,d[i].pen);
	}	  
	  

    }
}

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

#define T 53
#define P 11

struct Team {
	int n, solve, penal;
	int prob[P];
	Team() : n(0), solve(0), penal(0) {
		for(int i=0; i<P; ++i) prob[i] = 0;
	}
	Team(int pn) : n(pn), solve(0), penal(0) {
		for(int i=0; i<P; ++i) prob[i] = 0;
	}
	bool operator<(const Team &t) const {
		if(solve != t.solve) return !(solve < t.solve);
		if(penal != t.penal) return penal < t.penal;
		return n < t.n;
	}
};

int main() {
	int t, p, r, tID, pID, time; string message;
	while(cin >> t >> p >> r && t && p && r) {
		vector<Team> teams;
		for(int i=1; i<=t; ++i) teams.push_back(Team(i));
		for(int i=0; i<r; ++i) {
			cin >> tID >> pID >> time >> message;
			--tID; --pID;
			if(teams[tID].prob[pID]>=0) {
				if(message=="WRONG") {
					teams[tID].prob[pID] += 1;
				}else {
					teams[tID].solve += 1;
					teams[tID].penal += teams[tID].prob[pID]*1200 + time;
					teams[tID].prob[pID] = -1;
				}
			}
		}
		sort(teams.begin(), teams.end());
		for(int i=0; i<teams.size(); ++i) {
			cout << teams[i].n << " " << teams[i].solve << " " << teams[i].penal << endl;
		}
	}
	return 0;
}