
ZOJ Problem Set  1957
As you maybe know, the qualification for the European Soccer Championship 2000 is a tournament where in each group each team plays against each other team twice. Germany is in group 3 together with Turkey, Finland, Moldova and Northern Ireland. 14 games have been played and 6 are still to come. A quick look at the current standings might make you think that Northern Ireland is already out of the race. But that's wrong! Imagine Northern Ireland wins their three remaining games, Germany plays remis against Turkey and loses against Finland, and Moldova defeats Turkey. Then Northern Ireland is number one! For those who are not familiar with the scoring model: In each game a team gains 3 points for a victory, 1 point for a remis or 0 points for a loss. After all games have been played, teams are ranked according to points. In case of a tie, the additional tie breakers are: goal difference (i.e. goals scored  goals against), goals scored, and random choice, in that order. The question your program should answer is:
On the next n lines, the names of the teams will follow. Names are always shorter than 30 characters and do not contain whitespace. On the next line, there will be an integer g, representing the number of completed games. Finally, g lines will follow, each one describing one completed game in the form team1 team2 goals1 goals2. You may further assume that at most 10 games will be remaining and each team
has at least one remaining game to play. (This simplifies the problem a little.)
Group #2 Source: University of Ulm Local Contest 1999 