H. Contest Simulation
time limit per test
5 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

This is a simulation problem. Briefly speaking, you need to read the submissions of this contest, and output the ranking.

Hunan University is now holding a programming contest. This contest is based on ICPC rules but maybe a little different.

The contest is made of $$$n$$$ $$$(1 \le n \le 20)$$$ problems and $$$m$$$ $$$(1 \le m \le 2000)$$$ participants, each problem can be solved by any participant if they could.

During the contest, aiming to solve more problems by using less time, the participants could make submissions for any problem they want, one participant can make no more than one submission in one second, the submissions will be described as follows.

A submission contains the following information:

1. user name, denotes who makes this submission.

2. time, denotes when does this submission be made.

3. problem number, denotes which problem does this submission submit for.

4. status, denotes whether the problem is solved by this submission or not, the details of status are as follows:

AC means Accepted, if a submission turns out to be this status, the problem is solved by this participant at this time.

WA means Wrong Answer, TL means Time Limit Exceed, ML means Memory Limit Exceed, RE means Runtime Error, CE means Compilation Error, all these status mean that there must be some problems in this submission, thus this problem is not solved by this participant at this time.

The duration of this contest is exactly 5 hours, in other words, 300 minutes or 18000 seconds, participants can not make submissions before or after the contest.

When the contest ends in 5 hours, a ranking will be made for awards. Participants who solve more problems will be ranked in front of those who solve problems less than them. If two participants solve the same amount of problems, who has the less penalty will be ranked in front of the other participant.

The penalty is calculated in the following formula.

For a specific problem, if this participant never solved this problem during the contest, the penalty of this problem is $$$0$$$. If this participant first solved it at time $$$t_1$$$ minutes after the beginning of this contest, and before this first submission with status AC, there was $$$f$$$ submissions with WA, TL, ML and RE but except CE, the penalty of this problem is $$$t_1+20 \times f$$$.

The penalty of a participant is the sum of their penalty over all problems.

For example, Steve has the following submissions:

Steve 00:12:55 A CE

Steve 00:15:12 A WA

Steve 00:16:30 A AC

Steve 01:34:07 C TL

The penalty of Steve is $$$16+1 \times 20=36$$$. The first CE on problem A does not count for penalty and the same as the last TL on problem C since Steve tried but did not solve this problem.

If two participants have the same amount of problem solved, and the same penalty, whose user name is lexicographically smaller will be ranked in front of the other participant. That's so unfair right? But just take it. We don't want the rules to be more complex.

And finally, this ranking will be used for awards, you should output this ranking with some dividing lines, denotes who win the GOLD/SILVER/BRONZE medals. you could refer to the samples for the specific format.

The rules of medals awards are as follows.

The priority of the medals is: GOLD>SILVER>BRONZE.

At least $$$10\%$$$ of the participants win GOLD medal.

At least $$$30\%$$$ of the participants win SILVER medal or higher.

At least $$$60\%$$$ of the participants win BRONZE medal or higher.

If it is possible to distribute medals in several ways, the option with the smallest number of gold medals is chosen. If there are several such options, the option with the smallest number of silver medals is chosen. If there are several such options, the option with the smallest number of bronze medals is chosen. Thus, the distribution must be determined.

Now could you please solve this problem?

Input

The first line contains three numbers, $$$n$$$, $$$m$$$, and $$$t$$$ $$$(1 \le n \le 20, 1 \le m \le 2000, 0 \le t \le 2 \times 10^5)$$$, denotes the number of problems, the number of participants, and the number of submissions.

The next $$$m$$$ lines, each line contains one string $$$username_i$$$ $$$(1\le |username_i| \le 100)$$$, denotes the user name of the $$$i$$$-th participant. It is guaranteed that this string contains only English letters (lowercase and uppercase), numbers and '_'. No duplicate names incident would happen.

The next $$$t$$$ lines, each line contains four strings separated by spaces, $$$userame_i$$$, $$$time_i$$$, $$$problem_i$$$, and $$$status_i$$$ $$$(1 \le |username_i| \le 100, |time_i|=8, |problem_i|=1, |status_i|=2)$$$, denotes the information of the $$$i$$$-th submission.

it is guaranteed the following restrictions always being satisfied.

$$$username_i$$$ must be one of the $$$m$$$ usernames above.

$$$time_i$$$ is in the format of $$$HH:MM:SS$$$ $$$(0 \le HH \lt 5, 0 \le MM \lt 60, 0 \le SS \lt 60)$$$, for example, 01:23:45, 02:34:59, which means this submission was submitted on the $$$HH$$$ hours $$$MM$$$ minutes and $$$SS$$$ seconds after the contest begins.

No participant can make submission twice or more at the same second.

$$$problem_i$$$ is an uppercase English letter and $$$A \le problem_i \lt A+n$$$, $$$A$$$ means the uppercase letter 'A', and $$$A+n$$$ means the $$$n$$$-th letter after 'A'.

$$$status_i$$$ is a string contains only two letters, and it must one string in the list {"AC", "WA", "TL", "ML", "RE", "CE"}.

Notice that the input of submissions could be at any order.

Output

The output contains exactly $$$m+3$$$ lines, each line is either a dividing line or information of a specific participant in the ranking at that position.

If the $$$i$$$-th line is the participant information, and there are $$$d$$$ $$$(0 \le d \le min(3,i-1))$$$ dividing lines above, this line should be the information of the $$$i-d$$$-th participant in the ranking. The information contains 3 strings separated by spaces, their username, number of problems they solved, and their total penalty.

If the $$$i$$$-th line is the dividing line, just output "GOLD", "SILVER" or "BRONZE" in one line. The participants above this dividing line should be awarded with the corresponding medal or higher, and those participants below should not. For example, if this line is "SILVER", the participants above this line should be awarded with GOLD or SILVER medals but those below should not.

Examples
Input
13 10 16
Alice
Bob
ChinaBoy
Dingzhen_official
Eileen_Gu
Fulafu
Genshin
Huawei_Aiguo
IKEA
Jojo
Alice 00:00:00 M WA
Alice 00:01:20 M AC
Alice 01:20:32 A ML
Bob 00:07:19 D AC
Bob 00:09:23 E WA
Bob 00:20:27 E AC
Dingzhen_official 00:23:24 D AC
Dingzhen_official 01:34:17 E AC
Dingzhen_official 03:09:53 J AC
Dingzhen_official 03:27:03 H AC
Eileen_Gu 01:31:59 A AC
Eileen_Gu 01:31:58 B AC
Fulafu 01:31:00 A AC
Fulafu 01:31:01 B AC
Fulafu 01:31:20 B WA
Fulafu 01:31:30 B AC
Output
Dingzhen_official 4 513
GOLD
Bob 2 47
Eileen_Gu 2 182
SILVER
Fulafu 2 182
Alice 1 21
ChinaBoy 0 0
BRONZE
Genshin 0 0
Huawei_Aiguo 0 0
IKEA 0 0
Jojo 0 0
Input
1 2 3
Dingzhen_official
Eileen_Gu
Dingzhen_official 04:59:58 A CE
Dingzhen_official 04:59:59 A AC
Eileen_Gu 04:59:00 A AC
Output
Dingzhen_official 1 299
GOLD
SILVER
Eileen_Gu 1 299
BRONZE
Input
1 1 2
Dingzhen_official
Dingzhen_official 03:31:35 A WA
Dingzhen_official 04:59:59 A AC
Output
Dingzhen_official 1 319
GOLD
SILVER
BRONZE