April 10, 2001
2001 ACM Programming Contest Practice Problem
HMC Region

Filename: scoring.cc

The ACM competition has a somewhat unusual system of scoring participating teams. Each team is assigned two numbers: the number of problems they have successfully solved and a time value. Teams are ranked first according to the number of problems solved (more problems yields a better ranking) and ties are broken by the time value (less time yields a better ranking).

The time value for a particular team is computed according to the following rules:

  1. First, find the number of minutes from the start of the contest to the time that the team submitted its first correct solution for each problem it has correctly solved.


  2. Sum up all of the times obtained in part 1. (If a team has solved no problems, this sum will be zero.)


  3. Add 20 minutes (of penalty) for each incorrect solution the team has submitted for a problem before submitting a correct solution to the same problem. If the team has not yet submitted a correct solution to a problem, there is no time penalty for incorrect submissions for that problem. Also, incorrect submissions made after a correct submission for a particular problem should be ignored.


Input

The input will consist of a number of lines, each representing a problem submission. Each line will contain four whitespace-separated tokens: the first is a string designating a team's name, the second is the problem number submitted, the third is the floating-point number of minutes from the start of the contest at which this submission was made, and the fourth is a '0' or '1'. The '0' indicates that the submission was incorrect; the '1' indicates that the submission was correct and the problem was solved. No team name will consist of more than 8 characters.

Output

The output should contain one line for each distinct team in the input, placed in order of the teams' current ranking (with 1 being the best rank and higher numbers indicating sequentially lower ranks). Each line should contain, first, the rank of the current team; second, the team name; third, the number of problems that team has solved; and fourth, the time score for that team. Each item should be formatted according to the example below. Use spaces to separate items, rather than tabs and do not include trailing whitespace. Be sure there are two significant figures after the decimal point in each time score; no more than four digits to the left of the decimal point will be needed. (The numbers in the first line of the example output are there only to help align your output; they should not appear.)

Sample Input

dvry  3  10.44 1
dcoders     2   11.27   0
coderage   2   15.31   1
coderage   3   21.72   0
dcoders     3   22.05   1
coderage   3   23.10   1
caltech      1   123.28  0

Sample Output

12345678901234567890123456789
1   coderage    2    58.41
2   dvry        1    10.44
3   dcoders     1    22.05
4   caltech     0     0.00