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 loop(n, i) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;

using namespace std;
typedef long long ll;

int main()
{
    int t, p, r;
    while (cin >> t >> p >> r, t) {
        vector<vector<int>> result(t, vector<int>(3+p,0));
        loop (t, i) result[i][0] = i+1;
        loop (r, i) {
            int tid, pid, time;
            string msg;
            cin >> tid >> pid >> time >> msg;
            if (msg == "CORRECT") {
                if (result[tid-1][pid+2] != -1) {
                    result[tid-1][1]++;
                    result[tid-1][2] += result[tid-1][pid+2]*1200 + time;
                }
            } else {
                if (result[tid-1][pid+2] != -1)
                    result[tid-1][pid+2]++;
            }
        }
        sort(all(result),
                [](vector<int> a, vector<int> b) {
                    if (a[1] == b[1]) return a[2] < b[2];
                    return a[1] > b[1];
                });
        for (auto t : result)
            cout << t[0] << ' ' << t[1] << ' ' << t[2] << endl;
    }
}

C++: #include<bits/stdc++.h>
#define f first 
#define sf second.first 
#define ss second.second 
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P > iP;

int main(){
  int t,p,r;
  while(cin>>t>>p>>r&&t){
    iP a[51];
    int k[11][51]={};
    for(int i=1;i<=t;i++)a[i]=iP(0,P(0,-i));
    for(int i=0;i<r;i++){
      int ti,pi,m;
      string s;
      cin>>ti>>pi>>m>>s;
      if(s=="CORRECT")a[ti].f++,a[ti].sf-=m+k[pi][ti]*1200;
      else k[pi][ti]++;
    }
    sort(a+1,a+t+1);
    for(int i=t;i>0;i--)
      cout<<-a[i].ss<<" "<<a[i].f<<" "<<-a[i].sf<<endl;    
  }
  return 0;
}

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

using namespace std;

typedef pair<int, int> P;
typedef pair<int, P> PP;

bool comp(PP a, PP b) {
	if(a.second.first > b.second.first) {
		return true;
	} else if(a.second.first < b.second.first) {
		return false;
	} else {
		if(a.second.second < b.second.second) {
			return true;
		} else if(a.second.second > b.second.second) {
			return false;
		} else {
			if(a.first < b.first) {
				return true;
			} else {
				return false;
			}
		}
	}
	return true;
}

int main(void) {
	int t, p, r, team, problem, time;
	string msg;
	vector<int> ans, pn, wtmp;
	vector<vector<int> > wrong;
	vector<PP> tres;
	PP res;
	P aw;
	int i;

	while(true) {
		cin >> t >> p >> r;
		if((t == 0 && p == 0 && r == 0)||cin.eof()) { break; }
		wtmp.clear();
		ans.clear();
		pn.clear();
		wrong.clear();
		for(i = 0; i < p; i++) {
			wtmp.push_back(0);
		}
		for(i = 0; i < t; i++) {
			ans.push_back(0);
			pn.push_back(0);
			wrong.push_back(wtmp);
		}
		for(i = 0; i < r; i++) {
			cin >> team >> problem >> time >> msg;
			if(msg=="CORRECT") {
				ans[team-1]++;
				pn[team-1] += wrong[team-1][problem-1] * 1200 + time;
			} else {
				wrong[team-1][problem-1]++;
			}
		}
		tres.clear();
		for(i = 0; i < t; i++) {
			aw = P(ans[i], pn[i]);
			res = PP(i+1, aw);
			tres.push_back(res);
		}
		sort(tres.begin(), tres.end(), comp);
		
		for(i = 0; i < t; i++) {
			cout << tres[i].first << " " << tres[i].second.first << " " << tres[i].second.second << endl;
		}
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <cstring>
#include <cctype>
#include <sstream>
#include <set>
#include <map>
#include <queue>
#include <complex>
using namespace std;
#define REP(i,n) for(int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for(int i = a; i < (int)b; i++)
const int INF = 1<<28;
const int MAX_T = 55;
const int MAX_P = 20;

bool com(const pair<int, pair<int, int> >& left, const pair<int, pair<int, int> >& right) {
	if(left.second.first == right.second.first) {
		if(left.second.second == right.second.first)
			return left.first < right.first;
		else
			return left.second.second < right.second.second;
	}
	else
		return left.second.first > right.second.first;
}

int w[MAX_T][MAX_P];

int main() {
	int T, P, R;
	while(cin >> T >> P >> R, T|P|R) {
		vector< pair<int, pair<int, int> > > vp;
		REP(i, T)
			vp.push_back(make_pair(i+1, make_pair(0, 0)));
		REP(j, R) {
			int tid, pid, time;
			string message;
			cin >> tid >> pid >> time >> message;
			if(message == "CORRECT") {
					vp[tid-1].second.first++;
					vp[tid-1].second.second += w[tid][pid] * 1200 + time;
			}
			else if(message == "WRONG")
        ++w[tid][pid];
		}
		sort(vp.begin(), vp.end(), com);
		REP(i, vp.size())
			cout << vp[i].first << ' ' << vp[i].second.first << ' ' << vp[i].second.second << endl; 
	}
	return 0;
}

C++: #include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
typedef pair<ll, int> Pll;
int main()
{
  int T, P, R;
  while(cin >> T >> P >> R, T || P || R) {
    int point[T+1], miss[T+1][P+1], pena[T+1];
    CLR(pena), CLR(miss), CLR(point);
    FOR(i,0,R) {
      int in[3]; FOR(j,0,3) cin >> in[j];
      string mes; cin >> mes;
      if(mes[0] == 'C') {
        point[in[0]]++;
        pena[in[0]] += miss[in[0]][in[1]] * 1200 + in[2];
      } else {
        miss[in[0]][in[1]]++;
      }
    }
    vector<Pll> sum_point(T);
    FOR(i,0,T) {
      ll p = point[i+1] * 10000 - pena[i+1] - (i + 1);
      sum_point[i] = Pll(p, i + 1);
    }
    sort(sum_point.rbegin(), sum_point.rend());
    FOR(i,0,T) {
      int j = sum_point[i].second;
      cout << j << " " << point[j] << " " << pena[j] << endl;
    }
  }
  return 0;
}