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 USE_CPP11
// #define USE_PRINTF

#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <utility>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#include <complex>
#include <memory>
#include <sstream>

#ifdef USE_CPP11
#include <unordered_map>
#include <unordered_set>
#include <functional>
#endif

#define PRINT(obj) cout << obj << endl
#define REP(i, n) for(int (i) = 0; (i) < (n); i++)
#define SPACE " "

typedef long long ll;

const int INF = 1e9 + 10;

using namespace std;

namespace Scanner {
#ifdef USE_PRINTF
  int    nextInt()    { int    d; scanf("%d" , &d); return d; }
  float  nextFloat()  { float  f; scanf("%f" , &f); return f; }
  double nextDouble() { double f; scanf("%lf", &f); return f; }  
  string nextString() { string s; scanf("%s" , &s); return s; }
  ll     nextll()     { ll     l; scanf("%ll", &l); return l; }
#else
  int    nextInt()    { int    d; cin >> d; return d; }
  float  nextFloat()  { float  f; cin >> f; return f; }
  double nextDouble() { double f; cin >> f; return f; }  
  string nextString() { string s; cin >> s; return s; }
  ll     nextll()     { ll     l; cin >> l; return l; }
#endif

  string getLine() { 
    string input;
    getline(cin, input);
    return input;
  }
};

namespace myLibrary {
  vector<string> split(const string& str, char delim) {
    vector<string> ret;
    size_t current = 0, found;
    while ((found = str.find_first_of(delim, current)) != string::npos) {
      ret.push_back(string(str, current, found - current));
      current = found + 1;
    }
    ret.push_back(string(str, current, str.size() - current));
    return ret;
  }
  
#ifdef USE_CPP11
  ///
  /// higher-order functional
  /// This is something like map in haskell, python, etc.
  /// Sample usage:
  ///   vector<int> a = {1, 2, 3, 4, 5};
  ///   vector<int> b = myLibrary::_Map<int, int>(a, [](int n){
  ///     return n * n;
  ///   });
  /// Result:
  ///   b = 1, 4, 9, 16, 25
  ///
  template<typename T_IN, typename T_OUT, class Functor>
  vector<T_OUT> _Map(vector<T_IN> src, Functor func) {
    vector<T_OUT> ret;
    for (int i = 0; i < src.size(); i++) {
      ret.push_back(func(src[i]));
    }
    return ret;
  }
#endif

};

/// BEGIN //////////////////////////////////////////////////////////

struct State {
public:
  int teamID;
  int acCount;
  int waCount[11];
  int penalty;

  State():acCount(0), penalty(0) { 
    memset(waCount, 0, sizeof(waCount));
  }
};

int main() {
  while (true) {
    int T = Scanner::nextInt();
    int P = Scanner::nextInt();
    int R = Scanner::nextInt();
    
    if (T + P + R == 0) {
      break;
    }
    
    vector<State> score(T);
    
    REP(i, T) {
      score[i].teamID = i + 1;
    }

    REP(i, R) {
      int tID        = Scanner::nextInt() - 1;
      int pID        = Scanner::nextInt() - 1;
      int time       = Scanner::nextInt();
      string message = Scanner::nextString();
      if (message == "WRONG") {
        score[tID].waCount[pID]++;
      } else if (message == "CORRECT") {
        score[tID].acCount++;
        score[tID].penalty += score[tID].waCount[pID] * 1200 + time;
      }
    }

    sort(score.begin(), score.end(), [](State a, State b) {
      if (a.acCount == b.acCount) {
        return a.penalty < b.penalty;
      } else {
        return a.acCount > b.acCount;
      }
    });

    REP(i, T) {
      cout << score[i].teamID << SPACE << score[i].acCount << SPACE << score[i].penalty << endl;
    }
  }  

  return 0;
}
/// END   //////////////////////////////////////////////////////////

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

using namespace std;

class info {
public:
    int tid;
    int pen;
    int cor;
    int p[10];
    info() {
        tid = 0;
        pen = 0;
        cor = 0;
        for (int i = 0; i < 10; i++)
            p[i] = 0;
    }
};

bool cmp(const class info &a, const class info &b)
{
    return (a.cor > b.cor) || (a.cor == b.cor && a.pen < b.pen) ||
        (a.cor == b.cor && a.pen == b.pen && a.tid < b.tid);
}

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

    while (cin >> t >> p >> r, t || p || r) {
        info m[50];

        for (int i = 0; i < t; i++)
            m[i].tid = i + 1;

        for (int i = 0; i < r; i++) {
            int tid, pid, tm;
            string mes;

            cin >> tid >> pid >> tm >> mes;

            if (mes == "WRONG") 
                m[tid - 1].p[pid - 1]++;
            else if (mes == "CORRECT") {
                m[tid - 1].cor++;
                m[tid - 1].pen += m[tid - 1].p[pid - 1] * 1200 + tm;
            }
        }

        sort(m, m + t, cmp);

        for (int i = 0; i < t; i++)
            cout << m[i].tid << " " << m[i].cor << " " << m[i].pen << endl;
    }

    return 0;
}

C++: 3 3 5
3 1 800 WRONG
1 1 1200 CORRECT
3 1 1400 CORRECT
1 2 2400 CORRECT
1 3 3600 CORRECT
5 2 5
3 1 1000 WRONG
5 2 2000 CORRECT
3 1 2800 CORRECT
4 1 4000 CORRECT
5 1 5000 CORRECT
6 3 15
2 1 10 WRONG
3 3 15 WRONG
3 3 20 CORRECT
1 1 50 CORRECT
4 2 60 WRONG
1 2 70 WRONG
4 1 80 CORRECT
1 2 90 WRONG
1 2 150 CORRECT
3 1 160 WRONG
3 1 180 CORRECT
3 2 210 WRONG
5 3 500 CORRECT
4 2 720 CORRECT
5 1 1500 CORRECT
0 0 0