import std.stdio;
import std.algorithm;
import std.string;
import std.range;
import std.array;
import std.conv;
import std.complex;
import std.math;
import std.ascii;
import std.bigint;
import std.container;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

const real eps = 1e-10;

void main(){
	while(true) {
		auto tpr = readInts();
		auto t = tpr[0];
		auto p = tpr[1];
		auto r = tpr[2];
		if((t | p | r) == 0) return;

		auto w = new int[][](t, p);
		auto c = new int[][](t, p);
		auto penalty = new int[](t);
		for(int i; i < r; ++i) {
			auto l = readln.chomp.split;
			auto tid = l[0].to!int-1;
			auto pid = l[1].to!int-1;
			auto time = l[2].to!int;
			auto mess = l[3];
			if(mess == "CORRECT") {
				if(c[tid][pid] == 0) {
					c[tid][pid] = time;
					penalty[tid] += w[tid][pid] * 1200 + time;
				}
			} else {
				++w[tid][pid];
			}
		}
		int[] cp;
		for(int i; i < t; ++i) {
			cp ~= filter!("a > 0")(c[i]).array.length.to!int;
		}
		auto tid = iota(1, t+1).array;
		zip(cp, penalty, tid).sort!((a,b) => a[0] > b[0] || (a[0] == b[0] && a[1] < b[1]) || (a[0] == b[0] && a[1] == b[1] && a[2] < b[2]));
		for(int i; i < t; ++i) {
			writeln(tid[i], " ", cp[i], " ", penalty[i]);
		}
	}
}