Football Ranking

Time limit1sMemory limit128 MB

Problem

Several matches have been played in a football league. Compute the league ranking after those matches.

For each match, the winning team earns 3 points, each team earns 1 point for a draw, and the losing team earns 0 points.

The ranking is determined by these rules.

  • First, sort teams in descending order by the total number of points earned in all matches.
  • If only some teams are tied on points, create a new league containing exactly those teams. In that league, consider only matches played between those teams, then apply the same rules again.
  • If every team in the current league or tied group has the same number of points, compare goal difference, then goals scored, then number of wins, all computed from the full original league. If teams are still tied, the smaller team number ranks higher.

Write a program that outputs the final ranking of the league.

Input

The first line contains two integers N and K, the number of teams and the number of played matches. 1 <= N <= 100 and 1 <= K <= 1000. Teams are numbered from 1 to N.

Each of the next K lines describes one match in the form 'A B C:D'. This means that team A played team B, team A scored C goals, and team B scored D goals. 0 <= C, D <= 9.

Output

Output one line containing the team numbers from the highest-ranked team to the lowest-ranked team, separated by spaces.