As you may know, the qualifying round of a European soccer championship is played as a double round-robin: inside each group, every team plays every other team twice. In one such group, Germany plays alongside Turkey, Finland, Moldova and Northern Ireland. Fourteen games have already been played and six are still to come.
A quick glance at the current standings might make you think that Northern Ireland is already out of the race — but that is wrong! Suppose Northern Ireland wins all three of its remaining games, Germany draws with Turkey and loses to Finland, and Moldova beats Turkey. Then Northern Ireland finishes first!
For those unfamiliar with the scoring model: in each game a team earns 3 points for a win, 1 point for a draw, and 0 points for a loss. After every game has been played, the teams are ranked by total points. Ties are broken, in this order, by goal difference (goals scored minus goals conceded), then by goals scored, and finally by a random draw.
Considering every possible way the remaining games could turn out, your program must determine, for each team in the group, its highest possible and lowest possible final rank once the tournament is over.
The input consists of one or more test cases. Each test case has the following format:
team1 team2 goals1 goals2, meaning that team1 scored goals1 goals and team2 scored goals2 goals in that game.You may assume that at most 10 games remain to be played and that every team has at least one remaining game (this simplifies the problem a little).
The input is terminated by a line containing a single 0 in place of $n$.
For each test case, first print a line Group #x, where $x$ is the number of the test case (starting from 1).
Then print one line for each team, in the order the teams appear in the input. Each such line contains the team's name, a single space, the team's best possible rank, a minus sign -, and the team's worst possible rank.
Print a blank line between consecutive test cases.