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>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ALL(a) (a).begin(),(a).end()
#define pb(x) push_back(x)
#define ms(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(10) 
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef long long ll;
struct edge{ int from, to, cost; };

struct data{ int id, ac, pe; };
bool comp(const data& d1, const data& d2)
{
	if (d1.ac != d2.ac) return d1.ac > d2.ac;
	else return d1.pe < d2.pe;
}

int main()
{
	int t, p, r;
	while (cin >> t >> p >> r, t)
	{
		int wa[55][15];
		ms(wa, 0);
		data d[55];
		FOR(i, 1, t + 1) d[i] = data{ i, 0, 0 };
		REP(w, r)
		{
			int tid, pid, time;
			string mes;
			cin >> tid >> pid >> time >> mes;
			if (mes == "WRONG") wa[tid][pid] += 1200;
			else
			{
				d[tid].ac++;
				d[tid].pe += time + wa[tid][pid];
			}
		}
		sort(d + 1, d + t + 1, comp);
		FOR(i, 1, t + 1) cout << d[i].id << " " << d[i].ac << " " << d[i].pe << endl;
	}
	return 0;
}

C++: 
import java.io.*;
import java.util.*;

public class Main {
	FastScanner in = new FastScanner(System.in);
	PrintWriter out = new PrintWriter(System.out);
	
	class Team implements Comparable<Team> {
		int id, solve, penalty;
		int[] wrong;
		
		Team(int id, int solve, int penalty, int n) {
			this.id = id;
			this.solve = solve;
			this.penalty = penalty;
			wrong = new int[n];
		}
		
		@Override
		public int compareTo(Team t) {
			if (solve > t.solve) return -1;
			else if (solve < t.solve) return 1;
			else {
				if (penalty < t.penalty) return -1;
				else if (penalty > t.penalty) return 1;
				else return 0;
			}
		}
		
		@Override
		public String toString() {
			return (id+1) + " " + solve + " " + penalty;
		}
	}
	
	public void run() {
		while (true) {
			int T = in.nextInt(), P = in.nextInt(), R = in.nextInt();
			if (T == 0) break;
			
			Team[] team = new Team[T];
			for (int i = 0; i < team.length; i++) {
				team[i] = new Team(i, 0, 0, P);
			}

			for (int i = 0; i < R; i++) {
				int tid = in.nextInt();
				int pid = in.nextInt();
				int time = in.nextInt();
				String message = in.next();
				tid--; pid--;
				if (message.matches("WRONG")) {
					team[tid].wrong[pid]++;
				} else {
					team[tid].solve++;
					team[tid].penalty += time + team[tid].wrong[pid] * 1200;
				}
			}
			
			Arrays.sort(team);
			
			for (int i = 0; i < team.length; i++) {
				System.out.println(team[i].toString());
			}
		}
		out.close();
	}

	public static void main(String[] args) {
		new Main().run();
	}

	public void mapDebug(int[][] a) {
		System.out.println("--------map display---------");

		for (int i = 0; i < a.length; i++) {
			for (int j = 0; j < a[i].length; j++) {
				System.out.printf("%3d ", a[i][j]);
			}
			System.out.println();
		}

		System.out.println("----------------------------");
		System.out.println();
	}

	public void debug(Object... obj) {
		System.out.println(Arrays.deepToString(obj));
	}

	class FastScanner {
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;

		public FastScanner(InputStream stream) {
			this.stream = stream;
			//stream = new FileInputStream(new File("dec.in"));

		}

		int read() {
			if (numChars == -1)
				throw new InputMismatchException();
			if (curChar >= numChars) {
				curChar = 0;
				try {
					numChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (numChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		boolean isEndline(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String next() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		String nextLine() {
			int c = read();
			while (isEndline(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndline(c));
			return res.toString();
		}
	}
}

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

//define
#define ALL(a) a.begin(),a.end()
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define debug(x) if(1) cout<<#x<<":"<<x<<endl;
#define DEBUG(x) if(1) cout<<#x<<":"<<x<<endl;
#define ll long long

//constant
const int MOD=1000000007;
const int INF=INT_MAX/3-1;
const double EPS=1e-9;
const int dx[]={1,0,-1,0};
const int dy[]={0,1,0,-1};

//typedef
typedef vector<int> vi;
typedef vector<vector<int>> vvi;






int main(){
    int t,r,p;
    while(cin>>t>>p>>r,t){
        vvi team(t,vi(p,0));
        vector<tuple<int,int,int>> tem(t,make_tuple(0,0,0));
        REP(i,t)
            get<0>(tem[i])=i+1;
        REP(i,r){
            int tid,pid,time;
            string mes;
            cin>>tid>>pid>>time>>mes;
            tid--,pid--;

            if(mes=="CORRECT"){
                get<1>(tem[tid])++;
                get<2>(tem[tid])+=time+team[tid][pid]*1200;


            }
            if(mes=="WRONG")
                team[tid][pid]++;



        }
        REP(i,t)
            get<0>(tem[i]);
        sort(ALL(tem),
        [](tuple<int,int,int> lef,tuple<int,int,int> rig)
{return (get<1>(lef)>get<1>(rig)
        || get<1>(lef)==get<1>(rig) && get<2>(lef)<get<2>(rig)
        || get<1>(lef)==get<1>(rig) && get<2>(lef)==get<2>(rig) && get<0>(lef)<get<0>(rig));});

        for(int i=0;i<t;i++)
            cout<<get<0>(tem[i])<<" "<<get<1>(tem[i])<<" "<<get<2>(tem[i])<<endl;

    }

    return 0;
}