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 rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

class team {
  public:
    int tid;
    int score;
    int penalty;
    // bool compare(team, team);
};

bool compare (team i, team j) {
  if (i.score > j.score) return i.score > j.score;
  else return i.penalty > j.penalty;
}

int main() {
  int t, p, r;

  while (cin >> t >> p >> r) {// && t && p && r) {
    vector<int> corrects(t);
    fill(corrects.begin(), corrects.end(), 0);
    vector<vector<int>> wrongs(t);
    rep (i, t) wrongs[i].resize(p);
    rep (i, t) fill(wrongs[i].begin(), wrongs[i].end(), 0);
    vector<int> penalties(t);

    int tid, pid, time_;
    string message;
    // vector<int> tID(r);
    // vector<int> pID(r);
    // vector<int> time(r);
    // vector<string> message(r);

    rep (i, r) {
      cin >> tid >> pid >> time_ >> message;
      tid--; pid--;

      if (message == "CORRECT") {
        corrects[tid]++;
        penalties[tid] += wrongs[tid][pid] * 1200 + time_;
      }
      else if (message == "WRONG") {
        wrongs[tid][pid]++;
      }
    }

    vector<team> teams(t);

    rep (i, t) {
      teams[i].tid = i+1;
      teams[i].score = corrects[i];
      teams[i].penalty = penalties[i];
    }

    sort(teams.begin(), teams.end(), compare);

    rep (i, t) {
      cout << teams[i].tid << ' ' << teams[i].score << ' ' << teams[i].penalty << endl;
    }
  }
}

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

using std::cin;
using std::cout;
using std::endl;
using std::vector;
using std::string;

struct data_t {
	int ID;
	int correct;
	int pena;

	bool operator<( const data_t& right) const {
		if ( correct == right.correct) {
			if ( pena == right.pena ) {
				return ( ID < right.ID);
			}
			else {
				return ( pena < right.pena);
			}
		}
		else {
			return ( correct > right.correct );
		}
	}
};

int main(void) {
	int T,P,R;
	cin >> T;
	cin >> P;
	cin >> R;

	while (T!=0||P!=0||R!=0) {
		vector<data_t> data(T);
		vector< vector<int> > wrong(T, vector<int>(P,0));
		int team,prob,time;
		string mes;

		for (int i = 0; i < T; i++) {
			data[i].ID = i + 1;
			data[i].correct = 0;
			data[i].pena = 0;
		} 

		for (int i = 0; i < R; i++) {
			cin >> team;
			cin >> prob;
			cin >> time;
			cin >> mes;

			if (mes == "CORRECT") {
				data[team-1].correct++;
				data[team-1].pena += (wrong[team-1][prob-1] * 1200) + time;
			}
			else if (mes == "WRONG") {
				wrong[team-1][prob-1]++;
			}
		}

		std::sort(data.begin(), data.end());

		for (int i = 0; i < T; i++) {
			cout << data[i].ID << " " << data[i].correct << " " << data[i].pena << endl;
		}

		cin >> T;
		cin >> P;
		cin >> R;
	}
	return 0;
}

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

class Team
{
public:
  int tID, solved, penalty;
  Team(int _tID, int _solved, int _penalty)
    :tID(_tID), solved(_solved), penalty(_penalty) {}
  bool operator <(const Team& obj) const
  {
    if (this->solved == obj.solved) {
      if (this->penalty == obj.penalty)
	return this->tID < obj.tID;
      return this->penalty < obj.penalty;
    }
    return this->solved > obj.solved;
  }
};

int main()
{
  int T, P, R;
  while (cin >> T >> P >> R) {
    if ((T|P|R) == 0)
      break;

    vector<Team> team;
    for (int i = 0; i < T; ++i)
      team.push_back(Team(i, 0, 0));

    vector<vector<int> > log(T, vector<int>(P, 0));
    for (int i = 0; i < R; ++i) {
      int tID, pID, time;
      string message;
      cin >> tID >> pID >> time >> message;
      --tID;
      --pID;
      if (log[tID][pID] == -1)
	continue;

      if (message == "WRONG") {
	++log[tID][pID];
      } else {
	++team[tID].solved;
	team[tID].penalty += time + log[tID][pID]*1200;
	log[tID][pID] = -1;
      }
    }
    sort(team.begin(), team.end());

    for (int i = 0; i < T; ++i)
      cout << team[i].tID+1 << " " << team[i].solved << " " << team[i].penalty << endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

struct team {
  int id, cnt;
  int ac[10], wr[10];
  team() { cnt = 0; fill(ac, ac + 10, 0); fill(wr, wr + 10, 0); }
  friend int pena(team t) {
    int res = 0;
    for (int i = 0; i < 10; i++) {
      if (!t.ac[i]) continue;
      res += t.ac[i] + t.wr[i] * 1200;
    }
    return res;
  }
};

bool comp(const team &a, const team &b) {
  if (a.cnt != b.cnt) return a.cnt > b.cnt;
  int pa = pena(a), pb = pena(b);
  if (pa != pb) return pa < pb;
  return a.id < b.id;
}

int main(void) {
  int T, P, R;
  while (cin >> T >> P >> R, T) {
    vector<team> v(T);
    for (int i = 0; i < T; i++) {
      v[i].id = i + 1;
    }

    for (int i = 0; i < R; i++) {
      int t, p, tm;
      string ms;
      cin >> t >> p >> tm >> ms;

      if (ms == "CORRECT") {
        v[t - 1].cnt++;
        v[t - 1].ac[p - 1] = tm;
      } else {
        v[t - 1].wr[p - 1]++;
      }
    }
    sort(v.begin(), v.end(), comp);

    for (int i = 0; i < T; i++) {
      cout << v[i].id << " " << v[i].cnt << " " << pena(v[i]) << endl;
    }
  }

  return 0;
}

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


struct team{

	  int  id, c, p;
	  vector<int> w;
	  team(int i, int correct, int pena, int num_pro){
			id = i; c = correct; p = pena; w = vector<int>(num_pro+1,0);
	  }
	  bool operator < (const team& tgt) const {
			if(c != tgt.c) return c < tgt.c;
			if(p != tgt.p) return p < tgt.p;
			return id < tgt.id;
	  }

};

int main(){
	  
	  while(1){
			int t,p,r; cin >> t >> p >> r;
			if(!t) break;

			vector<team> teams;
			teams.push_back( team(10000,-1,1000000,10) );
			for(int i=1; i<=t; i++)
				  teams.push_back( team(i,0,0,p) );
			
			for(int i=0; i<r; i++){
				  int tid,pid,time;
				  string m;
				  cin >> tid >> pid >> time >> m;

				  if(m == "CORRECT"){
						teams[tid].c ++;
						teams[tid].p += teams[tid].w[pid] * 1200 + time;
				  }
				  else{
						teams[tid].w[pid]++;
				  }
			}
			sort(teams.begin(),teams.end());
			reverse(teams.begin(),teams.end());
			for(int i=0; i<t; i++)
				  cout << teams[i].id << " " << teams[i].c << " " << teams[i].p << endl;
				  
	  }
	  
}