Champions League


  • محدودیت زمان: ۱ ثانیه
  • محدودیت حافظه: ۲۵۶ مگابایت

UEFA Champions League is the most prestigious annual sport competition in the world. In this competition, European clubs are divided into 8 groups of 4 teams.

In group stage, teams are ranked according to some specific rules. For example Team A will be ranked above Team B if:

  • Team A has more points than Team B.
  • If their points are equal, Team A has higher goal difference than Team B.
  • In case of tie in all previous cases, Team A has scored more goals than Team B.
  • In case of tie in all previous cases, Team A has scored more Away Scored Goals than Team B.

It is guaranteed that there won’t be a tie after these rules.

Your task is to write a program to determine the group leaders (top 2 teams of each group) based on their results.

ورودی🔗

The input is describing 12 games which are played between teams of a group. Each line describes a game and its result. The length of each line doesn’t exceed 25.

The format of each line is: HomeTeamName HomeTeamGoals vs. AwayTeamGoals AwayTeamName

Teams’ names consist of English letters and space character.

The team with more scored goals wins the game and receives 3 points. In case of draw, both teams receive 1 point.

  • GoalDifference=ScoredGoalsRecievedGoalsGoalDifference = ScoredGoals - RecievedGoals
  • Away Goals = Number of goals scored (being away team)

خروجی🔗

Print the names of first team and the second team in the appropriate order. They must be printed in separate lines.

مثال‌ها🔗

ورودی نمونه ۱🔗

Man Utd 8 vs. 2 Arsenal
Lyon 1 vs. 2 Man Utd
FC Barca 0 vs. 0 Lyon
FC Barca 5 vs. 1 Arsenal
Man Utd 3 vs. 1 FC Barca
Arsenal 6 vs. 0 Lyon
Arsenal 0 vs. 0 Man Utd
Man Utd 4 vs. 2 Lyon
Arsenal 2 vs. 2 FC Barca
Lyon 0 vs. 3 FC Barca
Lyon 1 vs. 0 Arsenal
FC Barca 0 vs. 1 Man Utd
Plain text

خروجی نمونه ۱🔗

Man Utd
FC Barca
Plain text