시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB114330.000%

문제

The Afghanistan League of Football has grown larger in the last few years. Ranking the teams in the league is a very important part of every league, and people want to understand what the current status of the league is. The league administration wants to create a website and publish the match result for public access. They need a program that can generate the data for the ranking table based on the match results. Write a program to help them with this problem.

Note:

  • A team wins if they score more goals than the other team
  • A match is a draw if both teams score the same number of goals
  • A team will receive 3 points for each win, 1 for each draw, and a 0 for each loss
  • Sort the table based on points (higher first), number of wins (higher first), number of draw (higher first), number of loss (lower first), number of scored goals (higher first), and number of received goals (lower first)
  • To teams can play multiple times with each other.
  • Some teams may play more games than other teams, e.g.: in the left every team played 4 games. And in the right with the same number of teams, each played different numbers of games.

입력

First line contains the number of test cases (T): 0 < T < 1000

Next line contains the number of matches (M): 0 < M <= 256

Each next line contains the match result between two teams in this format:

  • team1 [team1_goals_count - team2_goals_count] team2 0 < len(team[1 and 2]) < 100, 0 <= team[1 and 2]_goals_count < 20
  • E.g.: Shahin [2 - 2] Hariwa

출력

Print the league table for each test case in the following format:

  • team-name,points,wins,draw,loss,goals-scored,goals-received E.g.: Shahin,12,3,0,0,10,2

Separate each test case output with an empty line (no empty line after the last testcase result).

예제 입력 1

1
6
team1 [2 - 0] team3
team1 [1 - 1] team2
team2 [4 - 7] team3
team2 [0 - 0] team1
team3 [5 - 3] team1
team3 [6 - 1] team2

예제 출력 1

team1,5,1,2,1,6,6
team2,2,0,2,2,6,14
team3,9,3,0,1,18,10

힌트