Problem C - Football Sort

Time Limit: 1 second

The Problem

Write a program, that given the fixtures of a football championship, outputs the corresponding classification following the format specified below. Win, draw and loss earn respectively three, one and zero points.

The criteria of classification are the number of points scored, followed by goal difference (goals scored minus goals suffered), and then scored goals. When more than one team have exactly the same number of points, goal difference, and scored goals, these are considered as having the same position in the classification.

The Input

The input will consist of a series of tests. Each test starts with a line containing two positive integers 28 ≥ T ≥ 1 and G ≥ 0. T is the number of teams and G is the number of games played. Follow then T lines, each containing the name of a squad. Squad names have up to 15 characters, and may only contain letters and dash characters ('-'). Finally the following G lines contain the score of each game. The scores are output with the following format: name of home team, number of goals scored by home team, a dash, number of goals scored by away team, and name of away team.

The input ends with a test case where T = G = 0 and should not be processed.

Output

The program shall output the classification tables corresponding to each input test separated by blank lines. In each table, the teams appear in order of classification, or alphabetically when they have the same position. The statistics of each team are displayed on a single line: team position, team name, number of points, number of games played, number of scored goals, number of suffered goals, goal difference, and percentage of earned points, when available. Note that if several teams have are in a draw, only the position of the first is printed. Fields shall be formatted and aligned as shown in the sample output.

Sample input

6 10
tA
tB
tC
td
tE
tF
tA 1 - 1 tB
tC 0 - 0 td
tE 0 - 0 tA
tC 0 - 0 tB
td 0 - 0 tE
tA 0 - 0 tC
tB 0 - 0 tE
td 0 - 0 tA
tE 0 - 0 tC
tB 0 - 0 td
2 2
Botafogo
Flamengo
Botafogo 3 - 2 Flamengo
Flamengo 2 - 3 Botafogo
5 10
tA
tB
tC
tD
tE
tA 0 - 0 tB
tC 0 - 0 tD
tE 0 - 0 tA
tC 0 - 0 tB
tD 0 - 0 tE
tA 0 - 0 tC
tB 0 - 0 tE
tD 0 - 0 tA
tE 0 - 0 tC
tB 0 - 0 tD
3 2
Quinze-Novembro
Flamengo
Santo-Andre
Quinze-Novembro 6 - 0 Flamengo
Flamengo 0 - 2 Santo-Andre
0 0

Sample output

 1.              tA   4   4   1   1   0  33.33
                 tB   4   4   1   1   0  33.33
 3.              tC   4   4   0   0   0  33.33
                 td   4   4   0   0   0  33.33
                 tE   4   4   0   0   0  33.33
 6.              tF   0   0   0   0   0    N/A

 1.        Botafogo   6   2   6   4   2 100.00
 2.        Flamengo   0   2   4   6  -2   0.00

 1.              tA   4   4   0   0   0  33.33
                 tB   4   4   0   0   0  33.33
                 tC   4   4   0   0   0  33.33
                 tD   4   4   0   0   0  33.33
                 tE   4   4   0   0   0  33.33

 1. Quinze-Novembro   3   1   6   0   6 100.00
 2.     Santo-Andre   3   1   2   0   2 100.00
 3.        Flamengo   0   2   0   8  -8   0.00