Programming-trampoline-athlon!#11750

Programming-trampoline-athlon!

1 second
128 megabytes
Easy

Programming competitions are fun and exciting. Programming should be an Olympic sport! At least, this is what we believe. However, when we suggested this to some of our friends, they did not seem to share our excitement. So, we decided to suggest a combined sport that will be more interesting to watch. Programming-trampoline-athlon! (we are still working on the name.)

The idea is as follows. This is a team sport, where each team comprises members. The team has at its disposal hour, computer, and trampoline. At all times, there must be at most one team member using the computer and at least one team member jumping the trampoline. At the beginning of the competition, the team is given programming problems, and trampoline elements (exercises). The team decides how to partition the trampoline elements between its members, such that each team member has to perform of the given elements on the trampoline. The programming tasks are solved cooperatively by the team members, but no one member can spend more than minutes on the computer in total. The scoring is comprised of two parts, which are added together:

Before we pitch this new sport to the International Olympic Committee, we want everything to be ready in order to show them just how serious we are. Thus, each team should receive a medal when no more than two other teams obtained a strictly higher score. However, in order to cope with a recent shortage of medals, the jury was instructed to make sure that there would be no more than teams deserving a medal. We ask you to write a program that determines the medallists, given the performance of the different teams.

Input

The first line contains the number n~(3 \le n \le 10^5) of competing teams. Then follow lines. Each of these lines describes a team and contains values c, p, e_1, e_2, e_3, e_4, e_5, e_6; is a five-letter code used to identify the team, p~(0 \le p \le 6) is an integer specifying the number of problems the team solved, and e_i~(0 \le e_i \le 10) is an integer specifying the execution score of trampoline element number . Different teams always have different team codes.

Output

Print m~(3 \le m \le 1000) lines, where is the number of medallists. Each line should represent a medallist team, by containing two values and , where is the team code and is the total score of the team. Medallist teams should be listed by decreasing total score and, in case of ties, by input order.

Examples

Example 1

Loading
Loading

Example 2

Loading
Loading