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 <iostream>
#include <string>
using namespace std;

struct Team{
  int team_num,time,correct;
};

int main(){
  Team data[51];
  while(1){
    int i,j,T,P,R; cin >> T >> P >> R;
    if ( T == 0 && P == 0 && R == 0 ) break;
    for( i = 1; i <= T; i++ ){
      data[i].time = 0;
      data[i].correct = 0;
      data[i].team_num = i;
      /* i???????????????????????????????????????????????????*/
    }

    int t,p,jikan,twrong[51][11];
    for( i = 0; i < 51; i++ ){
      for( j = 0; j < 11; j++ ){
	twrong[i][j]=0;
      }
    }
    string str;
    for( i = 0; i < R; i++ ){
      cin >> t >> p >> jikan >> str;
      if( str == "CORRECT" ){
	data[t].correct++;
	data[t].time = data[t].time + twrong[t][p] * 1200 + jikan;
      }else if( str == "WRONG" ){
	twrong[t][p]++;
      }
    }
    /* for( i = 0; i < T; i++ ){
      for( j = 1; j < T; j++ ){
	if( data[j].team_num > data[j+1].team_num ) 
	  swap( data[j],data[j+1] );
      }
      }*/

    for( i = 0; i < T; i++ ){
      for( j = 1; j < T; j++ ){
	if( data[j].time > data[j+1].time ) 
	  swap( data[j],data[j+1] );
      }
    }

    for( i = 0; i < T; i++ ){
      for( j = 1; j < T; j++ ){
	if( data[j].correct < data[j+1].correct ) 
	  swap( data[j],data[j+1] );
      }
    }

    for( i = 1; i <= T; i++ ){
      cout << data[i].team_num << " "
	   << data[i].correct << " " << data[i].time << endl;
    }
    
  }
  return 0;
}

C++: #include <bits/stdc++.h>
#define REP(i,n) for(i=0; i<n; i++)
#define IREP(i,n) for(i=n-1; i>=0; i--)
#define X first
#define Y second;
using namespace std;

struct R {
	int t, c, p;
	R() {
		c = 0;
		p = 0;
	}
	bool operator<(const R& another) const {
		if(c != another.c) return c > another.c;
		if(p != another.p) return p < another.p;
		return t < another.t; 
	}
};

int main() {
	int T,P,R,i,j,t,p,ti;
	string m;
	while(cin >> T >> P >> R, T!=0 || P!=0 || R!=0) {
		int a[T][P];
		REP(i,T) REP(j,P) a[i][j] = 0;
		struct R r[T];
		REP(i,T) {
			r[i].t = i+1;
			r[i].c = 0;
			r[i].p = 0;
		}
		REP(i,R) {
			cin >> t >> p >> ti >> m;
			t--;
			p--;
			if(a[t][p]==-1) continue;
			if(m=="WRONG") a[t][p]++;
			else if(m=="CORRECT") {
				r[t].c++;
				r[t].p += 1200*a[t][p] + ti;
				a[t][p] = -1;
			}
		}
		sort(&r[0], &r[T]);
		REP(i,T) {
			cout << r[i].t << ' ' << r[i].c << ' ' << r[i].p << endl;
		}
	}
	return 0;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,n) for(int i=(int)(n-1);i>=0;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define print(x) cout << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<int, P> PIP;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;
typedef set<int> S;

#define INF INT_MAX/3
#define MAX_N 1000000001

struct team {
    int id;
    int correct = 0;
    int wrong[10] = {};
    int penalty = 0;
};

bool operator<(const team &a, const team &b) {
    if (a.correct != b.correct) return a.correct > b.correct;
    if (a.penalty != b.penalty) return a.penalty < b.penalty;
    return a.id < b.id;
}


int main(){
    cin.sync_with_stdio(false);
    int t, p, r;
    while(cin >> t >> p >> r, t) {
        team tm[t];
        rep(i, t) tm[i].id = i + 1;
        rep(i, r) {
            int tid, pid, time;
            string msg;
            cin >> tid >> pid >> time >> msg;
            if (msg == "WRONG") tm[tid - 1].wrong[pid - 1]++;
            else {
                tm[tid - 1].correct++;
                tm[tid - 1].penalty += time + 1200 * tm[tid - 1].wrong[pid - 1];
            }
        }
        sort(tm, tm + t);
        rep(i, t) cout << tm[i].id << " " << tm[i].correct << " " << tm[i].penalty << endl;
    }

    return 0;
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cassert>
#include <vector>
#include <map>

using namespace std;
//map<char,bool> assign;
int assign;
bool formula(string &arg, int &pos){
    if('a' <= arg[pos] && arg[pos] <= 'k'){
        return assign & (1 << (arg[pos++]-'a'));
    }else if(arg[pos] == '-'){
        return !formula(arg, ++pos);
    }else if(arg[pos] == 'T'){
        pos++;
        return true;
    }else if(arg[pos] == 'F'){
        pos++;
        return false;
    }else{
        assert(arg[pos] == '(');
        bool f,b;
        char op;
        f = formula(arg, ++pos);
        op = arg[pos];
        assert(op == '*' || op == '+' || op == '-');
        if(op == '-') pos++;
        b = formula(arg, ++pos);
        assert(arg[pos] == ')');
        pos++;
        if(op == '*'){
            if(f&&b) return true;
            return false;
        }else if(op == '+'){
            if(!f&&!b) return false;
            return true;
        }else{
            if(f && !b) return false;
            return true;
        }
    }
}

bool parse(string &arg, int pos){
    bool f,b;

    f = formula(arg, pos);
    assert(arg[pos] == '=');
    b = formula(arg, ++pos);
    return f == b;
}


int main(){
    string str;
    while(cin >> str){
        if(str == "#") break;
        vector<char> vars;
        bool res = true;

        for(int i=0;i<(int)str.size();i++){
            if('a' <= str[i] && str[i] <= 'k'){
                vars.push_back(str[i]);
            }
        }

        for(int i=0;i<(1 << 10);i++){
            assign = i;
            res = parse(str, 0);
            if(!res) break;
        }
        if(res){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }
}