시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
2 초 512 MB 3 2 2 66.667%

문제

League football (known in some circles as soccer) has been played in England since 1888 and is the most popular winter game through most of Europe, just as rugby is in New Zealand. English newspapers and many Websites publish the latest results and the current tables.

With English football, each team plays every other team both home and away, and at the end of the season, the team with most points wins the title. Points are awarded for winning (3 points) or drawing (1 point each). Teams level on points are separated by the larger goal difference, that is goals for (ie scored) minus goals against (ie conceded). If this is level, the team who has scored more goals is placed first.

In this problem you will be given a list of teams and their current record, followed by a list of matches. You have to update the record of each team who has a result recorded and output a correctly sorted league table.

입력

The first line contains a single integer, T (8 <= T <= 30), which is the number of teams in the league. The next 2 x T lines each contain the current record of one team as follows:

<name>
<games played> <wins> <draws> <losses> <goals for> <goals against> <points>

The first line contains the team name which consists of one or more words, which may contain numbers. No name will be longer than 30 characters.

All numbers on the second line are non-negative integers.

The next line contains a single integer, G (0 < G <= (T/2)), which is the number of games recorded. There then follow 4 x G lines, each containing data on one game as follows:

<home team name>
<home team score>
<away team name>
<away team score>

The two teams will both be from the preceding list of teams. The scores will each be a non-negative integer less than 20.

출력

T lines giving the updated record of each team from the input, name followed by data all on 1 line. Teams are to be sorted by highest points, then highest goal difference, then most goals scored, then alphabetical order (case insensitive, numbers before letters).

예제 입력 1

18
Aston Villa
33 21 6 6 74 34 69
Sheffield United
34 18 12 4 63 33 66
Sunderland
33 18 3 12 47 34 57
Wolverhampton Wanderers
33 15 9 9 47 35 54
Newcastle United
34 13 10 11 53 43 49
Manchester City
33 13 8 12 49 41 47
Nottingham Forest
34 13 8 13 56 55 47
Derby County
33 13 8 12 43 42 47
Stoke City
34 13 8 13 37 45 47
Everton
33 13 7 13 46 30 46
Bury
33 13 6 14 40 57 45
Liverpool
33 13 5 15 47 45 44
Blackburn Rovers
33 12 4 17 47 60 40
West Bromwich Albion
34 11 8 15 43 51 41
Preston North End
33 12 4 17 37 45 40
Notts County
34 9 11 14 46 60 38
Burnley
34 11 5 18 34 54 38
Glossop
34 4 10 20 31 74 22
5
Aston Villa
3
Preston North End
1
Blackburn Rovers
2
Wolverhampton Wanderers
1
Derby County
2
Everton
1
Liverpool
2
Bury
0
Sunderland
3
Manchester City
1

예제 출력 1

Aston Villa 34 22 6 6 77 35 72
Sheffield United 34 18 12 4 63 33 66
Sunderland 34 19 3 12 50 35 60
Wolverhampton Wanderers 34 15 9 10 48 37 54
Derby County 34 14 8 12 45 43 50
Newcastle United 34 13 10 11 53 43 49
Manchester City 34 13 8 13 50 44 47
Liverpool 34 14 5 15 49 45 47
Nottingham Forest 34 13 8 13 56 55 47
Stoke City 34 13 8 13 37 45 47
Everton 34 13 7 14 47 32 46
Bury 34 13 6 15 40 59 45
Blackburn Rovers 34 13 4 17 49 61 43
West Bromwich Albion 34 11 8 15 43 51 41
Preston North End 34 12 4 18 38 48 40
Notts County 34 9 11 14 46 60 38
Burnley 34 11 5 18 34 54 38
Glossop 34 4 10 20 31 74 22