League Standings Score Sheet
There are league and tournament games in sports. In soccer leagues, points are awarded for wins, losses, and draws, and rankings are determined by those points. The points awarded for each are as follows: win (3 points), loss (0 points), and draw (1 point).
Create a program that inputs the number of teams and their league record, sorts them in order of good performance (based on the number of points) and outputs the team name and points. In case of a tie in points, output in the order of input.
Input
Multiple data sets will be given. Each data set will be in the following format:
n
name1 w1 l1 d1
name2 w2 l2 d2
:
namen wn ln dn
The number of teams, n (n ≤ 10), is given on the first line. On the following n lines, the name namei of team i (up to 20 alphabets), the number of wins wi, the number of losses li, and the number of draws di (0 ≤ wi, li, di ≤ 9) are given, separated by spaces.
When the number of teams is 0, the input is terminated. The number of data sets will not exceed 50.
Output
For each data set, output a list of the sorted teams. On the i-th line, output the name and points of the i-th team separated by a comma.
Insert one blank line between data sets.
Sample Input
4
Japan 1 0 2
Egypt 1 2 0
Canada 0 2 1
Spain 2 0 1
3
India 0 2 0
Poland 1 0 1
Italy 1 0 1
0
Output for the Sample Input
Spain,7
Japan,5
Egypt,3
Canada,1
Poland,4
Italy,4
India,0
