Programming Olympiad

Time Limit: 1 Second    Memory Limit: 32768 KB

The judges at the programming contest have been watching the Olympics, and are considering using style judging at next year's contest. Particularly, they like the model used in the diving competition where each problem is given a degree of difficulty and then six judges will give it a score on a scale from 0.0 to 10.0. The high and low score will be discarded, the other four scores added up, and then the sum is multiplied by the degree of difficulty. The team with the highest total score for all their problems is declared the winner.

Your job for this problem is to write a program that will read in the number of teams and problems, each problem's degree of difficulty, and the problems that are submitted by each team at an actual competition along with each of the six judges' scores for those problems. The program will then print a summary showing each team's score on each of the problems along with the winning team number and their score. A team is allowed to submit a problem more than once without penalty, but the judges' scores for the most recent submission are the ones that are used. In case more than one team has an overall score within three hundredths of a point of the high score, your program should indicate there is a tie and list the teams with multiple high scores.


Input

The input file will consist of data sets for one or more contests. Each data set will begin with a single integer 0 <= n <= 9, representing the total number of teams competing in the contest. This will be followed by a line that begins with an integer 0 < p <= 9 indicating the number of problems at the competition, and then p numbers representing the judges' difficulty ratings for each of the problems. Each of the difficulty ratings is a non-negative fixed point value with exactly one digit after the decimal point. All judges' scores are fixed point numbers in the range from 0.0 to 10.0 with one digit after the decimal point. The next lines contain a team's submission and the six judges' scores for that submission in the following format :

Team-Number Problem-Number Score1 Score2 Score3 Score4 Score5 Score6

The end of input for a given contest is indicated by the string "TIME'S UP" starting in column 1. A line of "END" starting in column 1 indicates end of input and should not be processed.

Output

The first line of output for each contest should be the number of the contest, where contest numbering starts with 1. The program should then print a summary showing the problem numbers, followed by a blank line, and then the team number of each team starting with the first team along with their total scores for each of the respective problems in a tabular format as shown below. All team and problem numbers are numbered with positive integers starting at 1 and continuing with each consecutive integer thereafter. The score for each team should be rounded to one digit to the right of the decimal point. This should be followed by a blank line, the team number(s) with the most points, and the overall winning point total.

Prob1 Prob2 Prob3 ... Probj

Team1 Score1 Score2 Score3 ... Scorej
Team2 Score1 Score2 Score3 ... Scorej
Team3 Score1 Score2 Score3 ... Scorej
...
Teami Score1 Score2 Score3 ... Scorej

Team x wins with xxx.x points

In case of a tie between two teams, the final line should be written in the following format:

Tie for first with xxx.x points among these teams : x x

If the tie is between more than two teams, simply continue listing your team numbers with a single space between each.

Have two blank lines after each contest.

Sample Input

4
3 2.1 1.9 1.8
2 2 6.0 2.1 6.5 7.0 8.0 7.5
1 2 1.9 5.0 6.5 7.0 7.0 5.5
3 1.8 5.5 8.5 7.0 6.0 6.0
4 3 2.3 7.0 7.0 7.0 7.0 7.0
2 3 2.3 7.0 7.0 7.0 7.0 7.0
2 1 1.9 5.0 6.5 7.0 7.0 5.5
1 1 1.9 5.0 6.5 7.0 7.0 5.5
3 1 1.9 5.0 6.5 7.0 7.0 5.5
2 3 8.0 7.5 7.5 8.0 7.5 7.0
1 3 6.9 5.5 6.5 7.5 7.0 8.5
4 2 5.5 7.5 7.0 7.0 8.0 7.5
TIME'S UP
END

Sample Output

Contest 1:
1 2 3

1 50.4 45.6 50.2
2 50.4 51.3 54.9
3 50.4 0.0 44.1
4 0.0 55.1 50.4

Team 2 wins with 156.6 points
Submit

Source: Southeast USA 2000