"You can make more friends in two months by becoming interested in other people than you can in two years by trying to get other people interested in you." - Dale Carnegie

After reading How to Win Friends and Influence People, Xorin decided that the only way to become an interesting individual (the kind that Xoranna would fancy) was by starting to slowly expand his social horizons, through attempting to experience new and unexpected hobbies.

This was the spark that ignited his passion for football. Aside from playing, Xorin also became an avid follower of tournaments. Our problem issues the most important football event - the World Cup.

Due to his lack of experience, Xorin has no favourite team. As a result, he will only follow the matches that take place in the first group of the championship. Like all other proud romanians (born and raised), he does not particularly enjoy losing, so he will choose to support the group's winning team for the rest of the competition. Your task is to provide him the final standings of the group, after all matches have been played.


After watching all matches, Xorin gives you the result of each match on one line of input, in the following manner:

TeamA TeamB GoalsA GoalsB


The output should respect the following format:


where the teams' order is as follows:

  • each winning team gets 3 points;
  • each match that results in a tie grants both teams 1 point;
  • each losing team gets 0 points;
  • teams are sorted decreasingly by the number of points they accumulate;
  • in case of equal points, multiple teams are sorted decreasingly by the total number of goals they have scored;
  • in case of equal points and equal goals, multiple teams are sorted alphabetically, in ascending order.


  • The group contains 4 teams.
  • Each two teams play exactly one match together. There is a total of 6 matches played, thus 6 lines of input.
  • Teams' names are made up of exactly one word, containing lowercase and/or uppercase English letters. No two teams share the same name.
  • Team names are no longer than 100 characters.
  • No team scores more than 10 goals in one match.
  • Since Xorin wants to take Xoranna out to the finals, his chances of her saying 'yes' would greatly increase if one of the finalists were the team he supports.


Brazil Croatia 3 1
Mexico Cameroon 1 0
Brazil Mexico 0 0
Cameroon Croatia 0 4
Cameroon Brazil 1 4
Croatia Mexico 1 3



Sponsors Gold