시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 17 5 5 50.000%

문제

대회가 끝이 나면 대부분의 참가자들은 어디서 꼬였는지에 대한 원망과 함께 좌절하게 된다.

심사위원들 또한 좌절한다. 제출 기록에 따라 각 참가자에게 점수를 매기고 순위를 산정해야 하기 때문이다.

비록 대회는 끝이 났지만 아직 코딩할 여력이 있다면, 심사위원들을 도울 순위 산정 프로그램을 만들어보자.

입력

첫 줄에 테스트 케이스의 수 K가 주어진다.

각 테스트 케이스의 첫 줄엔 세 개의 정수 M, N, P가 주어진다.

M은 대회에 사용된 문제의 개수이며 (1 ≤ M ≤ 10), N은 총 제출 수 (1 ≤ N ≤ 5000),

P는 참가자의 수 (1 ≤ P ≤ 500) 이다.

각 문제는 A, B, ... 로 이름붙여져 있으며, 참가자들은 1부터 P까지의 아이디를 갖는다.

이어 N개의 줄에 걸쳐 제출 기록의 내용이 주어진다.

제출 기록은 p m t j의 형식이며, p는 제출한 참가자(1, 2, ...) , m은 문제 번호(A, B, ..), t는 제출한 시각, j는 정답 여부이다.

j=0이라면 오답이며, j=1일 경우엔 정답이다.

제출 기록은 제출 시각이 감소하지 않는 순으로 주어진다.

문제를 맞힐 경우, 맞힌 사람은 총점에 문제를 맞힌 시각 + 그 문제를 틀린 횟수*20만큼을 더하게 된다.

만일 동일한 문제를 두 번 이상 맞히더라도 처음 맞힌 것만 인정된다.

출력

각 테스트 케이스마다 Data Set K: 를 출력한 뒤, 참가자들의 아이디, 푼 문제 수, 총점을 P줄에 걸쳐 1위부터 차례대로 출력한다.

순위는 푼 문제 수가 다르다면 푼 문제 수가 많은 사람이 높으며,

푼 문제 수가 같다면 총점이 낮은 사람이 순위가 높다.

어떤 테스트 케이스에서도 동점자가 나오는 경우는 없다.

각 테스트 케이스의 사이엔 빈 줄을 하나 출력한다.

예제 입력 1

2
4 6 3
2 C 11 0
1 B 24 1
2 C 25 1
1 C 40 0
3 D 55 1
2 B 55 1
2 8 2
1 A 8 0
2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